in reply to Matching arrays with different number of elements and element size
Hi, try the function all in the core module List::Util.
Output:use strict; use warnings; use feature 'say'; use List::Util 'any'; my @wanted = ( 'foo', 'bar', 'baz', 'missing' ); my @source = ( 'foo 42', '666 bar', 'baz (qux)' ); for my $wanted ( @wanted ) { if ( any { /$wanted/ } @source ) { say "Found $wanted"; } else { say "Cannot find $wanted"; } }
$ perl 1195036.pl Found foo Found bar Found baz Cannot find missing
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Matching arrays with different number of elements and element size
by Ksonar (Initiate) on Jul 14, 2017 at 04:37 UTC |