#!/usr/bin/perl #Program name: perlsort3.pl # sort numerically using a subroutine. # numbers are given in a file (specified on the command [one number per line]) $x = 0; while (<>) { $someList[$x] = $_; $x++; } @sortedLines = sort numbers @someList; print @sortedLines; sub numbers { if ($a < $b) { -1; } elsif ($a == $b) { 0; } else { +1; } }