Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Re: Referencing to a hash inside a hash of hashes.

by astaines (Curate)
on Aug 08, 2001 at 02:35 UTC ( [id://102925]=note: print w/replies, xml ) Need Help??


in reply to Referencing to a hash inside a hash of hashes.

this may make it a little clearer

#!d:\perl\perl my %hash; my %direc; my $record = { DIR => 3 }; $hash{'myhash'} = $record; print $hash{'myhash'},"\n"; ## Prints HASH(0x1b9f0b8) print $hash{'myhash'}{DIR},"\n"; ## Prints 3 $direc{'this'} = "something"; $direc{'that'} = "another"; #Here we swat the previous value of $hash{'myhash'} #the previous value of $hash{myhash} ($record) vanishes $hash{'myhash'}{DIR} = \%direc; print $hash{'myhash'}->{DIR}{'this'},"\n"; ## Prints something print $hash{'myhash'}{DIR}{'this'},"\n"; ## Prints something print $hash{'myhash'}->{DIR}{'that'},"\n"; ## Prints another print $hash{'myhash'},"\n"; ## Prints HASH(0x1b9f0b8) print $hash{'myhash'}{DIR},"\n"; ## Prints HASH(0x1b95778)
The point about the quotes is that double quotes interpolate variable into their contents before passing them on. Single quotes don't.
-- Anthony Staines

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others meditating upon the Monastery: (9)
As of 2024-04-19 07:56 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found