Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw

Re^3: hash question

by andal (Hermit)
on May 27, 2016 at 07:44 UTC ( #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?

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

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (4)
As of 2022-12-09 00:16 GMT
Find Nodes?
    Voting Booth?

    No recent polls found