Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Re^3: hash question

by andal (Hermit)
on May 27, 2016 at 07:44 UTC ( [id://1164279]=note: print w/replies, xml ) Need Help??


in reply to Re^2: hash question
in thread hash question

You are missing one slight catch. When you do

my $hash = shift;
you get pointer to the object passed to the function. When you do
$hash = {a => "alpha"};
you create new object and store its pointer in the variable that previously contained pointer to another object. Finally, when you do
%{ $hash } = ( a => 'alpha', b => 'beta' );
then you take object pointed by the variable and store in that object new set of keys.

You have to distinguish "objects" and "pointers to objects", the latter are called "references" in perl, then things may become more consistent for you.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others examining the Monastery: (5)
As of 2024-04-18 06:29 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found