[sf-perl] double filter (but short)

Randal L. Schwartz merlyn at stonehenge.com
Tue Jul 1 09:08:25 PDT 2008


>>>>> "Michael" == Michael Friedman <friedman at highwire.stanford.edu> writes:

Michael> I haven't tried this, but something like:
Michael> print reverse( map {s/^\([^:]*\):/_$1_:/} <> );

That's going to print the result of the s///, which will be a success/fail
boolean.  I also consider it bad form to modify $_ within the map block,
because sometimes it fails (read only), and is at least misleading.

I'd go with something like this:

print reverse map { /(.*):(.*)/ or die; "_$1_:$2\n" } <>;

-- 
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn at stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Smalltalk/Perl/Unix consulting, Technical writing, Comedy, etc. etc.
See http://methodsandmessages.vox.com/ for Smalltalk and Seaside discussion


More information about the SanFrancisco-pm mailing list