This may work better:
$ perl -le' my @array = ( "x y.g z 123", "a b.f c 456", "d b.c w 321" ); my @include = ( "b", "q" ); my @keep = map { my $item = $_; my $key = ( split )[ 1 ]; map $key =~ +/\Q$_/ ? $item : (), @include } @array; print for @keep; ' a b.f c 456 d b.c w 321
In reply to Re: filter an array with consecutive splits
by jwkrahn
in thread filter an array with consecutive splits
by coldy
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |