my @tmp; if ($match){ push @tmp, @line[@sorted_cols]; print "@tmp\n"; } push @arraynew,[@tmp];