Net::RRP::Toolkit - big hole of usefull methods :)


Net-RRP documentation  | view source Contained in the Net-RRP distribution.

Index


NAME

Top

Net::RRP::Toolkit - big hole of usefull methods :)

DESCRIPTION

Top

Net::RRP::Toolkit - big hole of usefull methods :) By default, methods not exported to caller namespape. You can export same methods to your namespace using

 use Net::RRP::Toolkit qw(method_list);

in your code;

decodeTilde($)

Decode leading tilde (~) in file path.

Example:

 use Net::RRP::Toolkit; 
 my $path = '~mkul/dvp/Classes'; 
 my $fullPath = Net::RRP::Toolkit::decodeTilde($path); 

OR

 use Net::RRP::Toolkit qw(decodeTilde);
 my $fullPath = decodeTilde('~mkul/dvp/Classes');

safeCall($)

safe call syscalls with repeat at EINTR errors

 use Net::RRP::Toolkit;
 my $result = Net::RRP::Toolkit::safeCall ( sub { open "qwa" } );
 die $! unless $result;

safeCopy(@)

safe copy files. 1) copy source file to temporary file 2) rename temporary file to destanation file

 input parameters: hash
   keys      =>    values
 Required parameters
   srcFile        source file name
   dstFile        destanation file name
 This parameters can be omited
   bufferSize     size of copy buffer, default is 128
   tmpMask        mask for temporary file name.
                  Default if "$toFileName.$$.$counter"

Permission of destanation file is equal of source file Source file is locked (lockf) by LOCK_SH Temporary destanation file locked by LOCK_EX

Return true if ok or die if errors.

example: use Net::RRP::Toolkit; Net::RRP::Toolkit::safeCopy ( srcFile => 'temp.passwd', dstFile => '/etc/passwd' );

lowerKeys($)

Lower all first level keys in hash

Input: hash reference.

Output: hash rerefence with lower keys

example: use Net::RRP::Toolkit; my $hash = { KEY1 => 1, KEY2 => { KEY3 => 3 }}; print Data::Dumper->Dump ( [ Net::RRP::Toolkit::lowerKeys ( $hash ) ] ) . "\n";

 output:
  { key1 => 1,
    key2 => { KEY3 => 3} }

pathSubtract($$)

Path subscraction routine

input: two _absolute_ directory paths

output: reletive path of first path concerning of second path

example: use Net::RRP::Toolkit; print Net::RRP::Toolkit::pathSubtract ( "/var/1", "/var/2" );

 output:
 ../2


Net-RRP documentation  | view source Contained in the Net-RRP distribution.