in reply to One-liners: Conditionals in Loops

You can avoid having to add the newline by using the -l CLO which simplifies things. Which if your array isn't too big makes it

perl -le"@a = <*.pl>; print for grep{ /\d{6}\./ } @a"

If your array might be very large, then flattening it to a list doubles your memory consumption, and takes extra time. If that's a danger, then using

perl -le" @a = <*.pl>; /\d{6}\./ and print for @a"

avoids those problems.


Examine what is said, not who speaks.
"Efficiency is intelligent laziness." -David Dunham
"Think for yourself!" - Abigail
Hooray!
Wanted!