my $infile="orders.txt"; my $output2 = 'orders_today.txt'; open (OUT, "+>$output2"); open (FILE, $infile) or die "ERROR: File does not exist\n"; for () { my @text =(); @text = split /\t/,$_; chomp @text; push (@text, $text[0]); push (@text, $text[1]); push (@text,$text[2]); push (@text,$text[3]); { $a->[10] cmp $b->[10] } print map @$_ }