|
Softpanorama |
May the source be with you, but remember the KISS principle ;-)
|
| News | Recommended Links | Perl Style | Perl Programming Environment | Perl as a command line utility tool | Perl Debugging |
|
|
AWK one liners | Shell Tips and Tricks | VIM Tips | Humor | Etc |
while (<INPUT>)
{
$DB::trace = 1, next if /debug/;
$DB::trace = 0, next if /nodebug/;
# more code
}
When run under the debugger, this enables tracing when the loop encounters an input line containing "debug" and ceases tracing upon reading one containing "nodebug". You can even force the debugger to breakpoint by setting the variable $DB::single to 1, which also happens to provide a way you can debug code in BEGIN blocks (which otherwise are executed before control is given to the debugger).
$cur_date='20060325';
(year, $month, $day)=$cur_date=~/(\d{4})(\d\d)(\d\d)/;
# --- process the second parameter
$msglevel=($ARGV[1]) ? $ARGV[1] : $msglevel; # defaults is the three digit constant(see below)
($msglevel1, $msglevel2, $testing) = split(//,$msglevel); # get flags
# Timestamp
#
($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst)=localtime(time);
$year+=1900;
$mon++;
for ($mon, $mday, $hour, $min, $sec) {
if (length($_)==1) {
$_="0$_";
}
}
link($_[0], $target);
if (-e $target) {
unlink($_[0]);
} else {
logger("SFail to move the file '$_[0]' to '$home/$_[1]/$target' \n");
return;
}
if ( $new{$match}++ || !( $tags{$match} = sprintf( "%s\t%s\t?^%s\$?\n", $match, $ARGV, $_ ) ) )
oreilly.com -- Online Catalog Perl Cookbook Chapter 8: File Contents (HTML Format)
Perl tips Understanding flow control
Copyright © 1996-2008 by Dr. Nikolai Bezroukov. www.softpanorama.org was created as a service to the UN Sustainable Development Networking Programme (SDNP) in the author free time. Submit comments This document is an industrial compilation designed and created exclusively for educational use and is placed under the copyright of the Open Content License(OPL). Original materials copyright belong to respective owners. Quotes are made for educational purposes only in compliance with the fair use doctrine.
Standard disclaimer: The statements, views and opinions presented on this web page are those of the author and are not endorsed by, nor do they necessarily reflect, the opinions of the author present and former employers, SDNP or any other organization the author may be associated with. We do not warrant the correctness of the information provided or its fitness for any purpose.
Last updated: June 02, 2008