#!/usr/local/bin/perl use strict; use warnings; my $file = "input.log"; open(IN, $file) || die "Couldn't find '$file': $!"; my @age; while (my $line = ) { chomp($line); my ($name, $age) = split(/\s*,\s*/, $line); push(@age, [ $name, $age ]); } close(IN); my @sorted_ages = sort { $b->[1] <=> $a->[1] } @age; foreach my $a (@sorted_ages){ print $a->[0], ' is ', $a->[1], ' years old.', $/; }