in reply to Re: Re: Regexp context with ||
in thread Regexp context with ||
See, your or is lower than the assignment. The assignment is happening at all times, assigning undef if the match fails.($a) = "abc" =~ /a(b)c/ or 'd'; print defined $a ? "defined as $a\n" : "undef\n"; # prints "defined as + b" ($a) = "abc" =~ /a(x)c/ or 'd'; print defined $a ? "defined as $a\n" : "undef\n"; # prints "undef"
So, that isn't the answer either.
Perhaps what you're looking for is:
($a) = "abc" =~ /a(b)c/ or $a = "d";
-- Randal L. Schwartz, Perl hacker
Be sure to read my standard disclaimer if this is a reply.
|
|---|