Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
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 perusing the Monastery: (15)
As of 2014-10-21 17:14 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    For retirement, I am banking on:










    Results (106 votes), past polls