Front page | perl.beginners |
Postings from April 2012
stacked processing
Thread Next
From:
Bryan Harris
Date:
April 9, 2012 03:03
Subject:
stacked processing
Message ID:
CBA68790.BBA9%lists@harrisfam.net
Hello there!
I love perl's ability to "stack" processing without intermediate variables,
e.g. to read in a pipe, strip off commented lines, pull out column 5, and
join, I can just do this:
$txt = join "", map { (split)[4] } grep { !/^#/ } <>;
What I haven't figured out is how to do a substitution in there, e.g. to
delete any leading blank lines out of the final string, but leave in others.
I'd love to be able to do this:
$txt = s/\A\n+// join "", map { (split)[4] } grep { !/^#/ } <>;
Is there a way to do something like that here?
- Bryan
Thread Next
-
stacked processing
by Bryan Harris