in reply to Re^3: regexp list return 5.6 vs 5.8
in thread regexp list return 5.6 vs 5.8
From what we've already discussed I would have expected the outcome:
- the return list is constructed at compile time.
- at runtime, the list (@x, @y) is evaluated in the caller's context, so it resolves to the comma operator, returning it's last argument - @y
- then the array @y is evaluated in the caller's context, which happens to be scalar, hence 4 as a result.
Pretty much the same as
perl -le '@x=qw(a b c);@y=qw(a b c d); $f=(@x,@y); print $f' 4
;-)
--shmem
_($_=" "x(1<<5)."?\n".q·/)Oo. G°\ /
/\_¯/(q /
---------------------------- \__(m.====·.(_("always off the crowd"))."·
");sub _{s./.($e="'Itrs `mnsgdq Gdbj O`qkdq")=~y/"-y/#-z/;$e.e && print}
|
---|
In Section
Seekers of Perl Wisdom