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
In reply to Re: Concise foreach expression
by johngg
in thread Concise foreach expression
by ram31
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |