in reply to Quick Sort Question

Something like this should work (not tested!):

use strict; use warnings; open my $fh, "<", "employees" or die "Cannot Open: $!"; my @employees; while (<$fh>) { chomp; if (/(.*):(1.*):(.*):(.*):(.*)/) { push @employees, [ $1, $2, $3, $4, $5 ]; } } close $fh; @employees = sort { $a->[2] cmp $b->[2] } @employees; for (@employees) { print join( "\t", @$_[ 2, 3, 0, 4 ] ), "\n"; }

Update: bug fixed

Replies are listed 'Best First'.
Re^2: Quick Sort Question
by thricewise (Initiate) on Dec 09, 2009 at 20:48 UTC
    I am getting an uninitialized value in join error if I try it the way you have it.

      Try  @$_[ 2, 3, 0, 4 ]

      (the for loop aliases individual arrayrefs to the default variable $_, which you need to dereference and slice)

        Have not even input that yet, but that's it...instant flash back to unix class from a few years ago, thanks!

      I warned that it's not tested, and the reason is that you didn't provide us with test input ;) I fixed the problem, that should be @$_[...] instead of @_[...]