Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Re^2: key and values help

by dsb (Chaplain)
on Aug 07, 2004 at 13:05 UTC ( #380898=note: print w/ replies, xml ) Need Help??


in reply to Re: key and values help
in thread key and values help

I like your solution, but I'm not sure what + is doing in this line:

push @{$groups{ +shift( @items ) }}, shift( @items );
I found this in perlop

Unary "+" has no effect whatsoever, even on strings. It is useful syntactically for separating a function name from a parenthesized expression that would otherwise be interpreted as the complete list of function arguments.

Is that what you were doing there? Making sure Perl knew that the return value from shift( @items ) was not part of an argument list?


dsb
This @ISA my cool %SIG


Comment on Re^2: key and values help
Download Code
Re^3: key and values help
by davido (Archbishop) on Aug 07, 2004 at 14:26 UTC

    You are close. Usually Perl sees any bareword placed in the position of a hash key as literal text, the actual key. The plus forces Perl to see it as an expression; in this case, a function, and evaluate it as a function using its return value as the hash's key.


    Dave

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://380898]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (7)
As of 2014-07-22 09:17 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (109 votes), past polls