Whats actually happening is that the hashes are flattened into a list, then this list is assigned to a new hash.
So, %h1 and %h4 wind up with the same contents below:
#!/usr/bin/perl -wT
use strict;
my @a1 = ('jan','January','feb','February');
my @a2 = ('mar','March', 'apr','April');
my %h1 = (@a1, @a2); # Two arrays become one h
+ash
my %h2 = ('jan','January','feb','February');
my %h3 = ('mar'=>'March' ,'apr'=>'April'); # '=>' is really just a c
+omma
my %h4 = (%h2,%h3); # Hashes get flattened an
+d behave
# nearly the same as the
+two
# arrays did above
print "h1\n";
print "\t$_ => $h1{$_}\n" for (sort keys %h1);
print "h4\n";
print "\t$_ => $h4{$_}\n" for (sort keys %h4);
=OUTPUT
h1
apr => April
feb => February
jan => January
mar => March
h4
apr => April
feb => February
jan => January
mar => March
-Blake
|