All day I've had that old Velvet Underground song
stuck in my head as I slowly discover all the ways
in which my
former Perl coding practices sucked.
One small example:
To iterate through my @test = ('this','that','the other','thing') I used to write:
foreach $num (@test) {
print $test[$num] . "\n";
}
or even worse:
for($num=0;$num<@test;$num++) {
print $test[$num] . "\n";
}
I now simply bang out:
print $_ . "\n" foreach @test;
The less typing the better. Noone can accuse me of
not being lazy. Other examples that have really changed my Perl world view include
Ovid's node
Death to dot star!, which really got me thinking about character classes and
tilly's
unique way of calling subs.
Armed with this knowledge, I've been producing faster, more maintainable scripts for fun and profit.
Many thanks to all the saints (and you lesser creatures, too) who toil to enlighten the flock.
Some people work very hard but still they never get it right
Well, I'm beginning to see the light
aside: Please do not ++ this node as it's not an XP trap. My sincerest thanks to the community.
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, details, 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, summary, 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.