in reply to Match a Variable to Only the True Statement
It's not clear to me exactly what you're trying to do, but I wonder if perhaps you need an | "ordered alternation" operator:
c:\@Work\Perl\monks>perl -wMstrict -le "my $p1 = qr{ Foo }xms; my $p2 = qr{ Bar }xms; my $p3 = qr{ Zot }xms; ;; my $str = 'Bar'; ;; if (my ($m) = $str =~ m{ \A ($p1 | $p2 | $p3) \z }xms) { print qq{matches: has '$m'}; } " matches: has 'Bar'
Update:
my ($m1) = $output =~ /^(pattern1)$/ or my ($m1) = $output =~ /^(pattern2)$/ or my ($m1) = $output =~ /(pattern3)/BTW: An expression like the one quoted above, with multiple masking variables (i.e., variables having the same name) defined in the same scope is never a good idea, and Perl would have told you about this ugly situation had you enabled warnings with a use warnings; statement at the top of your program. Especially for those just starting with Perl, always use warnings; and use strict; at the start of your code.
Give a man a fish: <%-{-{-{-<
|
|---|