Let's say I have an array of strings, e.g. @matches = ("cat", "zebra", "apple"), and I want to open a file and try to match these strings in the simplest way possible.
while (<MYFILE>)
{
chomp;
if (..some match condition...)
{
..stuff..
}
}
I could just use a foreach on each line to try to match, but I know there's got to be a concise way in Perl to say "if string X matches any of the patterns in array Y." I just can't seem to find this anywhere.
EDIT:
To clarify, here's the highly inefficient code:
while (<MYFILE>)
{
chomp;
foreach $m (@matches)
{
if (~ /$m/)
{
..stuff..
}
}
}
I know there's some shorthand method of doing this.
any-junction