use strict; use warnings; my @ages; while( my $line = ) { chomp $line; # get rid of the pesky newline my ( $name, $age ) = split( ', ', $line ); # name isn't used now push( @ages, $age ); # add each $age to the @ages array } @ages = sort { $b <=> $a } @ages; print join( "\n", @ages ); __DATA__ Charley, 34 Sam, 3 Lucy, 18