Your skill will accomplish what the force of many cannot |
|
PerlMonks |
Re^2: Perl/Ruby comparisonby JadeNB (Chaplain) |
on Dec 25, 2009 at 20:44 UTC ( [id://814374]=note: print w/replies, xml ) | Need Help?? |
His Perl could have been tightened up considerably. Boy, is that a call to action! I can't believe I'm the first in 4 years to have taken it up …. Here's a more-or-less faithful copy:
To me, this task suffers, rather than benefits, from the names, and is much better suited for a Unix-style pipeline; fortunately, Perl is good at those (although I resort to substr to avoid the to-me unsatisfying s///; $_): I've replaced the test for whether the CONTACTME field == 1 (not eq "1", ugh) with a test for whether it's true, since that's almost certainly what was meant; but it's easy to change it back. Finally, note that, since the CONTACTME field is not carrying any useful information, we might as well avoid printing it; so we could define replace the outer map by map { chomp; [ map {...} snip_or_toss split "\t" ] }, and then get rid of the grep.
In Section
Seekers of Perl Wisdom
|
|