In scalar context? A false scalar.
In list context? Nothing. It returns zero scalars.
is just a fancy way of writinga => 'a' =~ m/b/, b => 'asdf'
'a', 'a' =~ m/b/, 'b', 'asdf'
The expression within the hash constructor ({}) is evaluated in list context. Since the above list was evaluated in list context, it's individual elements were evaluated in list context. On a failed match, the above is therefore equivalent to
'a', 'b', 'asdf'
Solutions:
a => scalar( 'a' =~ m/b/ ), b => 'asdf'
a => !!( 'a' =~ m/b/ ), b => 'asdf'
a => 'a' =~ m/b/ ? 1 : 0, b => 'asdf'
In reply to Re: What does a failed regular expression match actually return?
by ikegami
in thread What does a failed regular expression match actually return?
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |