http://qs1969.pair.com?node_id=917668


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