Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

RE: strange looking code

by BlaisePascal (Monk)
on Oct 20, 2000 at 18:11 UTC ( [id://37665]=note: print w/replies, xml ) Need Help??


in reply to strange looking code

It looks perfectly understandable to me...

%r ends up having the keys (a,b,c,d,e,f,g,h,i,j) and their respective values (A,B,C,D,E,F,G,H,I,J)

The line @A{keys %r} = keys %r; causes %A to have the keys (a,b,c,d,e,f,g,h,i,j) and the respective values (a,b,c,d,e,f,g,h,i,j).

In the final line, print %A, "\n";, %A is being used in a list context, and thus looks like a list of key-value pairs, like so: (a,a,b,b,c,c,d,d,e,e,f,f,g,g,h,h,i,i,j,j), which gets printed out with no delimiters between each element as aabbccddeeffgghhiijj, which is what you saw.

That help?

Replies are listed 'Best First'.
RE: RE: strange looking code
by Jonathan (Curate) on Oct 20, 2000 at 18:27 UTC
    Thanks for that BlaisePascal and kilinrax, I can see what its doing just don't recognise the construct. - I first thought -w and use strict would moan and was surprised when it didn't

    "We are all prompted by the same motives, all deceived by the same fallacies, all animated by hope, obstructed by danger, entangled by desire, and seduced by pleasure." - Samuel Johnson
      I believe @foo{ LIST } = LIST is a hash slice, just by way of terminology.

      Philosophy can be made out of anything. Or less -- Jerry A. Fodor

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others sharing their wisdom with the Monastery: (5)
As of 2024-03-28 13:03 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found