in reply to Concise foreach expression
I agree that grep is the way to tackle this but just to show another way with a ternary as the argument to print and a statement modifier.
$ perl -Mstrict -Mwarnings -E ' my @arr = qw{ sdyudf attest reer fittest }; print m{test} ? qq{$_\n} : () for @arr;' attest fittest $
I hope this is of interest.
Cheers,
JohnGG
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Concise foreach expression
by ram31 (Novice) on Aug 29, 2014 at 12:32 UTC |