I prefer
sub printlog {
print LOG @_ unless $nolog;
}
printlog "======== done =========\n";
to
print LOG "======== done =========\n" unless $nolog;
as it makes for less clutter. It is also beneficial in
that, with a little more work, $nolog doesn't
have to pollute the namespace.
BEGIN {
my $nolog = 0;
sub setlog {
$nolog = shift;
}
sub printlog {
print LOG @_ unless $nolog;
}
}
setlog 1;
printlog "======== done =========\n";
I like to generalise this functionality to handle debug/production screen output and/or
log file output.
-- g r i n d e r
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
|
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.
|
|