Help for this page

Select Code to Download


  1. or download this
    %hash = ( Elliot => Babbage,
              Charles => Babbage,
    ...
        ($key, $value) = each %$hashref;
        print "$key => $value\n";
    }
    
  2. or download this
    my %data = (bananas => 1,oranges => 7,apples => 12, mangoes => 3,pears
    + => 8,);
    # Using <=> instead of cmp because of the numbers
    foreach my $fruit (sort {$data{$a} <=> $data{$b}} keys %data) {
        print $fruit . ": " . $data{$fruit} . "\n";
    }