Audit::DBI::Utils - Utilities for the Audit::DBI distribution.
Version 1.8.2
use Audit::DBI::Utils; my $ip_address = Audit::DBI::Utils::integer_to_ipv4( $integer ); my $integer = Audit::DBI::Utils::ipv4_to_integer( $ip_address ); my $differences = Audit::DBI::Utils::diff_structures( $data_structure_1, $data_structure_2, comparison_function => sub { my ( $a, $b ) = @_; $a eq $b; }, #optional ); my $diff_string_bytes = Audit::DBI::Utils::get_diff_string_bytes( $differences );
my $string = Audit::DBI::Utils::stringify_data_structure( data_structure => $data_structure, object_stringification_map => { 'Math::Currency' => 'as_float', }, );
Convert a 32-bits integer representing an IP address into its IPv4 form.
my $ip_address = Audit::DBI::Utils::integer_to_ipv4( $integer );
Convert an IPv4 address to a 32-bit integer.
my $integer = Audit::DBI::Utils::ipv4_to_integer( $ip_address );
Return the differences between the two data structures passed as parameter.
By default, if leaf nodes are compared with '==' if they are both numeric, and with 'eq' otherwise.
An optional comparison_function parameter can be used to specify a different comparison function.
my $differences = Audit::DBI::Utils::diff_structures( $data_structure_1, $data_structure_2, ); # Alternative built-in comparison function. # Leaf nodes are compared using 'eq'. my $diff = Audit::DBI::Utils::diff_structures( $data_structure_1, $data_structure_2, comparison_function => 'eq', ); # Alternative custom comparison function. my $diff = Audit::DBI::Utils::diff_structures( $data_structure_1, $data_structure_2, comparison_function => sub { my ( $variable_1, $variable2 ) = @_; # [...] return $is_equal; } );
Return the size in bytes of the string differences. The argument must be a diff structure returned by Audit::DBI::Utils::diff_structures().
Audit::DBI::Utils::diff_structures()
This function has two modes:
Relative comparison (default):
In this case, a string change from 'TestABC' to 'TestCDE' is a 0 bytes change (since there is the same number of characters).
my $diff_string_bytes = Audit::DBI::Utils::get_diff_string_bytes( $diff_structure );
Absolute comparison:
In this case, a string change from 'TestABC' to 'TestCDE' is a 6 bytes change (3 characters removed, and 3 added).
my $diff_string_bytes = Audit::DBI::Utils::get_diff_string_bytes( $diff_structure, absolute => 1, );
Note that absolute comparison requires String::Diff to be installed.
Return the size in bytes of all the strings contained in the data structure passed as argument.
my $string_bytes = Audit::DBI::Utils::get_string_bytes( 'Test' ); my $string_bytes = Audit::DBI::Utils::get_string_bytes( [ 'Test1', 'Test2' ] ); my $string_bytes = Audit::DBI::Utils::get_string_bytes( { 'Test' => 1 } );
Note: this function is recursive, and will explore both arrayrefs and hashrefs.
Please report any bugs or feature requests through the web interface at https://github.com/guillaumeaubert/Audit-DBI/issues/new. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.
You can find documentation for this module with the perldoc command.
perldoc Audit::DBI::Utils
You can also look for information at:
GitHub's request tracker
https://github.com/guillaumeaubert/Audit-DBI/issues
AnnoCPAN: Annotated CPAN documentation
http://annocpan.org/dist/Audit-DBI
CPAN Ratings
http://cpanratings.perl.org/d/Audit-DBI
MetaCPAN
https://metacpan.org/release/Audit-DBI
Guillaume Aubert, <aubertg at cpan.org>.
<aubertg at cpan.org>
Copyright 2010-2014 Guillaume Aubert.
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License version 3 as published by the Free Software Foundation.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/
To install Audit::DBI, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Audit::DBI
CPAN shell
perl -MCPAN -e shell install Audit::DBI
For more information on module installation, please visit the detailed CPAN module installation guide.