Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Re^3: join two hashes

by johngg (Canon)
on Jul 31, 2011 at 02:05 UTC ( [id://917668]=note: print w/replies, xml ) Need Help??


in reply to Re^2: join two hashes
in thread join two hashes

One way to ease the brain ache is to use Data::Dumper to visualise your data structures.

knoppix@Microknoppix:~$ perl -MData::Dumper -Mstrict -wE ' > my %rep = ( one => 123, two => 456 ); > my %comb = ( one => 987, two => 654 ); > my %new = map { $_, [ $rep{ $_ }, $comb{ $_ } ] } keys %rep; > print Data::Dumper->Dumpxs( > [ \ %rep, \ %comb, \ %new ], > [ qw{ *rep *comb *new } ] > ); > say q{-} x 30; > push @{ $new{ two } }, 888; > $new{ three } = { four => 444, five => 555 }; > print Data::Dumper->Dumpxs( [ \ %new ], [ qw{ *new } ] );' %rep = ( 'one' => 123, 'two' => 456 ); %comb = ( 'one' => 987, 'two' => 654 ); %new = ( 'one' => [ 123, 987 ], 'two' => [ 456, 654 ] ); ------------------------------ %new = ( 'three' => { 'five' => 555, 'four' => 444 }, 'one' => [ 123, 987 ], 'two' => [ 456, 654, 888 ] ); knoppix@Microknoppix:~$

I hope this is helpful.

Cheers,

JohnGG

Replies are listed 'Best First'.
Re^4: join two hashes
by planetscape (Chancellor) on Sep 30, 2011 at 16:53 UTC
Re^4: join two hashes
by koolgirl (Hermit) on Jul 31, 2011 at 02:22 UTC

    It does, actually, works just like tylenol! I'm actually trying to learn how to work with modules at the moment, because I really haven't been doing much of that at all and I know I'm limiting my growth by not, so this is a great starting point for me to begin working with one on a specific point of interest. Thanks :D

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others wandering the Monastery: (4)
As of 2024-04-19 23:14 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found