Help for this page

Select Code to Download


  1. or download this
    $ cat pm_1198871_a.pl
    use strict;
    ...
    Joe Smith 25
    Bob Jones 43
    Sue Parker 57
    
  2. or download this
    # Parallel arrays: Sort our data by age
    my @indices = sort { $age[$a] <=> $age[$b] }  0 .. $#first_name;
    ...
        print "$first_name[$i] $last_name[$i] $age[$i]\n";
    }
    
  3. or download this
    # Array of hashes: Sort our data by age
    @people = sort { $a->{age} <=> $b->{age} } @people;
    ...
    for my $hr (@people) {
        print "$hr->{first} $hr->{last} $hr->{age}\n";
    }
    
  4. or download this
    my $ma = {
        first=>'Morticia', last=>'Addams', age=>undef, favorite_color=>'bl
    +ack',
    ...
        my $addr = shift;
        print "$addr->{street_num} $addr->{street_name}\n$addr->{city} $ad
    +dr->{st} $addr->{zip}\n";
    }