#!/usr/bin/perl # first we open the temp file w/the records to be sorted, place in an array $input = 'frecord.tmp'; $i = 0; open (input) || die "Can't open file $input: $!\n"; @data = ; $datalength = @data; # array length close input; @sorted = sort { @a_fields = split/\s+/, $a; @b_fields = split/\s+/, $b; $a_fields[3] <=> $b_fields[3]; } @data; $sortedlength = @sorted; for ($i=0; $i<=$sortedlength; $i++) { print "$sorted[$i] \n"; }