Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Merge 2 hashes which contains duplicate Keys

by slayedbylucifer (Scribe)
on Sep 25, 2012 at 18:40 UTC ( #995613=perlquestion: print w/ replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    my %h1 = (    "one"   => 1,
                  "two"   => 2,
    ...
                "six"   => 6,
                "one"   => 2222,
                );  
    
  2. or download this
    $VAR1 = {
              'one' => [ 1, 2222 ]
    ...
              'five' => 5,
              'six' => 6,
            };
    
  3. or download this
    #!/usr/bin/perl -w
    
    ...
            push @{ $h1{$x} }, $h2{$x};
    }
    print Dumper (\%h1);
    
  4. or download this
    Can't use string ("1") as an ARRAY ref while "strict refs" in use at s
    +lice_hash.pl line 48
    
  5. or download this
    $VAR1 = {
              'three' => 3,
    ...
                          4
                        ]
            };
    

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (4)
As of 2015-07-05 16:19 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 (67 votes), past polls