If I understood you correctly, here's a quick way to match what's in an array:
my $switch = 'quick'; my @array = qw(the quick fox jumped over the lazy dog); my %matches = map {$_,1} @array; my $match = exists $matches{ $switch } ? 1 : 0; print $match;
Note that this technique is only useful if you have many items to match. Otherwise, use grep:
my $match = grep { /$switch/ } @array;
With the latter, $match is set to zero if no match is found. Otherwise, it's set to one.
Cheers,
Ovid
Update: Rereading my response and I've concluded that I haven't had enough coffee. I wonder whose question I was answering? :)
Join the Perlmonks Setiathome Group or just click on the the link and check out our stats.
In reply to (Ovid) Re: skipping until an alement is matched
by Ovid
in thread skipping until an alement is matched
by Amoe
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |