Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

%+ and scope

by oha (Friar)
on Jan 04, 2013 at 10:10 UTC ( #1011596=perlquestion: print w/replies, xml ) Need Help??
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 976633

Replies are listed 'Best First'.
Re: %+ and scope
by Anonymous Monk on Jan 04, 2013 at 10:14 UTC

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://1011596]
Front-paged by Corion
help
Chatterbox?
[karlgoethebier]: now it's getting weird...
[GotToBTru]: 'getting'?
[Discipulus]: why karlgoethebier ?
[GotToBTru]: ugh .. what's the term for comparing versions of an algorithm to determine which is most efficient?
[hippo]: Benchmarking?
[GotToBTru]: hippo++

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (12)
As of 2017-06-22 12:49 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    How many monitors do you use while coding?















    Results (519 votes). Check out past polls.