5% assure discount from here only

Tuesday, August 7, 2012

(31) How to concatenate hashref or merge hashref?

Solution:

Perl provide  very easy way to concatenate or merge hashref data.

my $a = {1 => 2, 3 => 4};
my $b = {5 => 6, 7 => 8};

my $c = {%$a, %$b};

print Dumper($c);

Output will be like this :-

$VAR1 = {
 '1' => '2',
 '3' => '4',
 '5' => '6',
 '7' => '8',
};