SPUG:Best One-Liners and Scripts for UNIX
Brian Hatch
spug at ifokr.org
Sun Apr 20 13:55:20 CDT 2003
> I was glad to see that most postings also refrained from needless
> stylistic variations, like the "backwards" phrasings that some
> cherish but teachers like myself tend to eschew, such as "print
> if $true".
I frequently use 'print if $true' style programming when it
makes sense. First, it keeps code more concise because you
don't span lines. Second, but more important, is that it
can be used to write perl code that more closely maps with
our thought processes themselves:
do_something if i_should
do_something unless i_shouldnt
follow my primary language - english - very well.
However this is best used when the default or desired thing
is on the left.
die if something_very_unusual_happened
is bad form, instead you should stick to
if something_very_unusual_happened {
die
}
or
something_very_unusualy_happened and die
These keep the important things on the left, so as you skim
the code, everything is in the same place. Similarly
print stuff_to_file if $log_everything_verbosely
makes more sense - you can see that a print is the stuff we
really want to do, except in rare cases.
--
Brian Hatch "The future reveals
Systems and itself only reluctantly"
Security Engineer
http://www.ifokr.org/bri/
Every message PGP signed
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
Url : http://mail.pm.org/pipermail/spug-list/attachments/20030420/b0e156b3/attachment.bin
More information about the spug-list
mailing list