NAME

App::MBUtiny::Util - Internal utilities used by App::MBUtiny module

VERSION

Version 1.03

SYNOPSIS

    use App::MBUtiny::Util qw/
            filesize explain hide_password md5sum
            resolv sha1sum
        /;

    my $fsize = filesize( $file );
    print explain( $object );
    print hide_password('http://user:password@example.com');
    my $md5 = md5sum( $file );
    my $name = resolv( $IPv4 );
    my $sha1 = sha1sum( $filename );

DESCRIPTION

Internal utility functions

explain
    print explain( $object );

Returns Data::Dumper dump

filesize
    my $fsize = filesize( $file );

Returns file size

hide_password
    print hide_password('http://user:password@example.com'); # 'http://user:*****@example.com'

Returns specified URL but without password

md5sum
    my $md5 = md5sum( $filename );

See Digest::MD5

node2anode
    my $anode = node2anode({});

Returns array of nodes

parse_credentials
    my ($user, $password) = parse_credentials( 'http://user:password@example.com' );
    my ($user, $password) = parse_credentials( new URI('http://user:password@example.com') );

Returns credentials pair by URL or URI object

resolv
    my $name = resolv( $IPv4 );
    my $ip = resolv( $name );

Resolv ip to a hostname or hostname to ip. See "resolv" in Sys::Net, "inet_ntoa" in Socket and "inet_aton" in Socket

set2attr
    my $hash = set2attr({set => ["AttrName Value"]}); # {"AttrName" => "Value"}

Converts attributes from the "set" format to regular hash

sha1sum
    my $sha1 = sha1sum( $filename );

See Digest::SHA1

xcopy
    xcopy( $src_dir, $dst_dir, [ ... exclude rel. paths ... ] );

Exclusive copying all objects (files/directories) from $src_dir directory into $dst_dir directory without specified relative paths. The function returns status of work

    xcopy( "/source/folder", "/destination/folder" )
        or die "Can't copy directory";

    # Copying without foo and bar/baz files/directories
    xcopy( "/source/folder", "/destination/folder", [qw( foo bar/baz )] )
        or die "Can't copy directory";

HISTORY

See Changes file

AUTHOR

Serż Minus (Sergey Lepenkov) http://www.serzik.com <abalama@cpan.org>

COPYRIGHT

Copyright (C) 1998-2019 D&D Corporation. All Rights Reserved

LICENSE

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

See LICENSE file and https://dev.perl.org/licenses/