#!/usr/bin/perl -w use strict; my @mega = ( ["AGCT", "0", "370", "1"], ["AGGT", "3", "52", "1"], ["TGAA", "2", "233", "0"], ["AGAG", "0", "32", "0"] ); open ( fh, ">junk.txt" ); for my $row (@mega) { print fh (join ":", @{$row}) . "\n"; } close fh; my $shellout = <<`SHELL`; sort -n -t: -k2,4 junk.txt SHELL print "$shellout\n";