Help for this page

Select Code to Download


  1. 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'
    
  2. or download this
    use strict;
    use warnings;
    
  3. or download this
    my %hash = ();
    
  4. or download this
    for ($i = 1;$i <= $#line;$i++)
    {
    ...
        $hash{$d}{$i}=$line[$i];
        print "$hash{$d}{$i}\n";
    }
    
  5. or download this
    {apple}{1} = 'red'
    {apple}{2} = 'green'
    
  6. or download this
    {apple}{red}
    {apple}{green}
    
  7. 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";
    }
    
  8. or download this
    }
    close (MYFILE);
    
  9. or download this
    foreach my $key (keys %hash)
    {
    ...
            print "key = '$key'   subkey = '$subkey'\n";
        }
    }