#!/usr/bin/perl -w use strict; use Data::Dump qw(pp); my @AoA; while() { my @cols = split; push @AoA, [@cols]; } @AoA = sort{ $a->[1] <=> $b->[1] or $a->[0] cmp $b->[0] or $a->[4] <=> $b->[4] or $b->[6] <=> $a->[6] }@AoA; pp \@AoA; =prints [ ["xhahhxha", 60, 3, "shdgehsh", 8, 1, 150], #this one ["xhahhxha", 60, 3, "jrthtahtat", 8, 1, 110], ["xhahhxha", 60, 3, "hahaghagah", 10, 1, 101], ["hsghtahs", 100, 19, "shdgehsh", 10, 20, 400], #this one ["hsghtahs", 100, 19, "jrthtahtat", 10, 20, 300], ["hsghtahs", 100, 19, "hahaghagah", 10, 20, 200], ] =cut my %seen; @AoA = grep{!$seen{"$_->[1]"."$_->[0]"}++}@AoA; #first of new col1,2 combo pp \@AoA; =prints [ ["xhahhxha", 60, 3, "shdgehsh", 8, 1, 150], ["hsghtahs", 100, 19, "shdgehsh", 10, 20, 400], ] =cut __DATA__ xhahhxha 60 3 hahaghagah 10 1 101 xhahhxha 60 3 jrthtahtat 8 1 110 xhahhxha 60 3 shdgehsh 8 1 150 hsghtahs 100 19 hahaghagah 10 20 200 hsghtahs 100 19 jrthtahtat 10 20 300 hsghtahs 100 19 shdgehsh 10 20 400