Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Re^3: Hashes and Memory

by Jeri (Scribe)
on Sep 08, 2011 at 17:37 UTC ( [id://924883]=note: print w/replies, xml ) Need Help??


in reply to Re^2: Hashes and Memory
in thread Hashes and Memory

Actually, I understand it.

My question is how can I put the coordinates in @c if the hash has not been dereferenced? or am I doing (and thinking) about this all wrong?

Replies are listed 'Best First'.
Re^4: Hashes and Memory
by Kc12349 (Monk) on Sep 08, 2011 at 18:13 UTC

    You don't need to dereference the hash ref into a standard hash variable to use it. As the previous poster said, this will make a copy of the hash instead of editing the original. You can use a hash ref just as you would a standard hash by dereferencing as needed. Below are comparisons of some common hash syntax.

    Hash Hash Ref my %hash = (key=>'value'); my $hash_ref = {key=>'value'}; $hash{key} = 'mod_value'; $hash_ref->{key} = 'mod_value'; print $hash{key}; print $hash_ref->{key}; my @keys = keys %hash; my @keys = keys %{$hash_ref};
Re^4: Hashes and Memory
by RichardK (Parson) on Sep 09, 2011 at 09:37 UTC

    Have a look at perlreftut for the tutorial on references. That should tell you everything you need to know :)

Re^4: Hashes and Memory
by Jeri (Scribe) on Sep 09, 2011 at 15:46 UTC
    Got everything working! Thanks Everyone!

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others chilling in the Monastery: (4)
As of 2024-04-26 08:03 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found