- or download this
C:\Steve\Dev\PerlMonks\P-2013-10-06@2342-Hash-Of-Hashes>FruitColor1b.p
+l
strawberry red green rose
...
key = 'green' subkey = 'strawberry'
key = 'red' subkey = 'strawberry'
key = 'red' subkey = 'apple'
- or download this
use strict;
use warnings;
- or download this
my %hash = ();
- or download this
for ($i = 1;$i <= $#line;$i++)
{
...
$hash{$d}{$i}=$line[$i];
print "$hash{$d}{$i}\n";
}
- or download this
{apple}{1} = 'red'
{apple}{2} = 'green'
- or download this
{apple}{red}
{apple}{green}
- or download this
foreach my $color (@colors) # Was: for ($i = 1;$i <= $
+#line;$i++)
{
$hash{$color}{$fruit} = 1; # Was: $hash{$d}{$i}=$line
+[$i];
print "Added hash{$color}{$fruit}\n"; # Was: print "$hash{$d}{$i
+}\n";
}
- or download this
}
close (MYFILE);
- or download this
foreach my $key (keys %hash)
{
...
print "key = '$key' subkey = '$subkey'\n";
}
}