#!/usr/local/bin/perl use strict; use warnings; open (my $sort_fh, '+<', 'C:\temp\SORT.CSV') or die "Cannot open file $!\n"; my @sorted = map {$_->[0]} sort { $a->[6] cmp $b->[6] || $a->[2] cmp $b->[2] || $a->[5] cmp $b->[5] || $a->[9] <=> $b->[9]} map {chomp;[$_,split(/,/)]} <$sort_fh>; seek $sort_fh, 0, 0; foreach(@sorted) { printf $sort_fh "$_\n"; }