bsb has asked for the wisdom of the Perl Monks concerning the following question:
At DB<2> below the result is '1' instead of the
'b' I expected.
It seems like the regexp is getting
a scalar context for some reason.
What is going on?
DB<1> ($a) = ("abc" =~ /a(b)c/); print $a b DB<2> ($a) = (("abc" =~ /a(b)c/) || 'd'); print $a 1 DB<3>($a) = (("ac" =~ /a(b)c/) || ('d')); print $a d
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Regexp context with ||
by hv (Prior) on Apr 09, 2003 at 02:00 UTC | |
by bsb (Priest) on Apr 09, 2003 at 02:30 UTC | |
by JamesNewman (Initiate) on Apr 09, 2003 at 18:56 UTC | |
|
Re: Regexp context with ||
by tachyon (Chancellor) on Apr 09, 2003 at 02:50 UTC | |
|
Re: Regexp context with ||
by graff (Chancellor) on Apr 09, 2003 at 02:08 UTC | |
by JamesNC (Chaplain) on Apr 09, 2003 at 02:55 UTC | |
by merlyn (Sage) on Apr 09, 2003 at 03:48 UTC |