in reply to filter an array with consecutive splits
Assuming that the second character of an a.b element is always a single lower case alpha, here's one solution:
>perl -wMstrict -le "my @array = ('x y.g z 123', 'a b.f c 456', 'd b.c w 321'); my @include = qw(b q); my ($include) = map qr{ \b [$_] \b }xms, join '', @include; my $second = qr{ \b [[:lower:]] \b }xms; my $element = qr{ $include \. $second }xms; my @keep = grep m{ $element }xms, @array ; print qq{'$_'} for @keep; " 'a b.f c 456' 'd b.c w 321'
Updates:
|
|---|