oha has asked for the wisdom of the Perl Monks concerning the following question:
Hi,
I found a strange behavior while trying to return values from %+:
perl -E 'sub foo { local $_ = shift; m{(?<a>\d++)}; say "IN ", @+{qw(a +)}; return @+{qw(a)} } say "OUT ",foo("12.34.56");' IN 12 OUT
I was expecting to get the same result, but apparently the list become empty when exiting the scope.
adding a map (return map { $_ } @+{qw(a)}) fix the issue, and it does not show by just returning $+{a}.
Am i missing something or there's something wrong?
TIA
update: see Bizarro %+ hash slice bug in Perl 5.10 to 5.14.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: %+ and scope
by Anonymous Monk on Jan 04, 2013 at 10:14 UTC |
Back to
Seekers of Perl Wisdom