Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
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 (Abbot) 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 browsing the Monastery: (5)
As of 2015-07-02 23:21 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (47 votes), past polls