in reply to sorting and array by [2]

You're leaving out important steps. You need to 1) read in the file, 2) split it and put into an array ref, and 3) sort it.
for (sort third_field <INPUT>) { print "Record: $_"; } sub third_field { my $x = (split ' ', $a)[2]; my $y = (split ' ', $b)[2]; $x <=> $y; }
You might want to do a map-sort-map:
for (by_third_field <INPUT>) { print "Record: $_"; } sub by_third_field { map $_->[0], sort { $a->[3] <=> $b->[3] } map { [ $_, split ] } @_; }

_____________________________________________________
Jeff[japhy]Pinyan: Perl, regex, and perl hacker, who'd like a job (NYC-area)
s++=END;++y(;-P)}y js++=;shajsj<++y(p-q)}?print:??;