Script::Toolbox

Script::Toolbox is a Perl framework for the daily business scripts.
Download

Script::Toolbox Ranking & Summary

Advertisement

  • Rating:
  • License:
  • Perl Artistic License
  • Price:
  • FREE
  • Publisher Name:
  • Matthias Eckardt
  • Publisher web site:
  • http://search.cpan.org/~eckardt/Script-Toolbox-0.22/Toolbox.pm

Script::Toolbox Tags


Script::Toolbox Description

Script::Toolbox is a Perl framework for the daily business scripts. Script::Toolbox is a Perl framework for the daily business scripts.SYNOPSIS use Script::Toolbox qw(:all); or use Script::Toolbox qw(Open Log Exit Table Usage Dir File System) $e = Script::Toolbox->new(); # # logging # Log( "log message" ); # log to STDERR Log( "log message", 'STDERR' ); # log to STDERR Log( "log message", 'STDOUT' ); # log to STDOUT Log( "log message", '/tmp/x' ); # log to /tmp/x Log( "log message", new IO::File "/tmp/XXX" ); # log to /tmp/XXX Script::Toolbox->new({logdir=>{mod=>'=s',desc=>'Log directory', mand=>1,default=>'/var/log'}}); Log( "log message" ); # log to /var/log/.log Log( "log message",'syslog','severity','tag' ); # log via syslogd # # print formatted tables like: # print join "n", @{$t}; $t = $e->Table( ); $t = $e->Table( , '|'); $t = $e->Table( , , , ); $t = $e->Table({ 'title' => 'Hash example', 'head' => , 'data' => , , ]}); $t = $e->Table({ 'title' => 'Hash with automatic column heads (F1,F2,F3)', 'data' =>}); # # command line options # $tb=Script::Toolbox->new({file=>{mod=>'=s',desc=>'Description', mand=>1,default=>'/bin/cat'}}); $file = tb->GetOpt('file'); # depricated, use the following $file = tb->{'file'}; $old = tb->SetOpt('newFile'); Usage(); # print a usage message for all options # if available print also the POD Usage('This is additional text for the usage'); # # Directory handling # $arrRef = Dir('/tmp' ); # all except . and .. $arrRef = Dir('/tmp', '.*patt' ); # all matching patt $arrRef = Dir('/tmp', '!.*patt' ); # all not matching patt # # File handling # $arrRef = File('path/to/file'); # read file into array $arrRef = File("/bin/ps |"); # read comand STDOUT into array File( "> path/to/file", 'override the old content' ); File( "path/to/file", 'append this to the file' ); File( "path/to/file", $arrRef ); # append array elements File( "path/to/file", $arrRef, $recSep ); # append array elements File( "path/to/file", $hashRef, $recSep, $fieldSep); # append as key value lines File( "| /bin/cat", "Hello world.n" ); $fileHandle = TmpFile(); # open new temporary file $arrRef = TmpFile($fileHandle) # read temp whole file # # Miscelleanous # Exit( 1, "Exit message" ); # exit with returncode 1, # write exit message via Log() $fh = Open( "> /tmp/xx" ); # return an IO::File object with # /tmp/xx opened for write # die with logfile entry if failed $fh = Open( "/bin/ps |" ); # return an IO::File object # die with logfile entry if failed $rc = System("/bin/ls") # execute a system command and # report it's output into the # logfile. $now = Now(); printf "Day:%d Mon:%d Year:%d Wday:%d Yday:%d IsDST:%d Sec:%d Min:%d Hour:%d", $now->{mday}, $now->{mon}, $now->{year}, $now->{wday}, $now->{yday}, $now->{isdst}, $now->{sec}, $now->{min}, $now->{hour}; $now = Now('"%A, %B %d, %Y"'); # Monday, October 10, 2005=head1 ABSTRACTThis module should be a "swiss army knife" for the daily tasks. The main goals are command line processing, automatic usage messages, signal catching (with logging), simple logging, simple data formatting, simple directory and file processing.Requirements:· PerlWhat's New in This Release:· new parameter Now({diff=>})· bug fixing in test t03_Exit


Script::Toolbox Related Software