Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re: Adding to hash of hashes

by 2teez (Priest)
on Aug 24, 2012 at 23:56 UTC ( #989658=note: print w/ replies, xml ) Need Help??


in reply to Adding to hash of hashes

but then I want to add an end => 10 to the same anonymous hash without replacing what's already there

use warnings; use strict; use Data::Dumper; my %hoh; $hoh{element1} = {start => 1, middle => 5}; print Dumper \%hoh; $hoh{element1}{end}=10; # add to hash print Dumper \%hoh;
OUTPUT:
$VAR1 = { 'element1' => { 'middle' => 5, 'end' => 10, 'start' => 1 } };
For more information, please check the following: perldsc, perlref, perllol, perldata, perlobj


Comment on Re: Adding to hash of hashes
Select or Download Code
Re^2: Adding to hash of hashes
by Dlamini (Novice) on Aug 25, 2012 at 02:55 UTC

    Thanks, 2teez, that's exactly what I was looking for - I think I tried something similar but must have got the syntax wrong somewhere

Re^2: Adding to hash of hashes
by AnomalousMonk (Monsignor) on Aug 25, 2012 at 04:45 UTC

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (8)
As of 2014-07-28 04:23 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (185 votes), past polls