seek $ifh, 0, 0; my @file = <$ifh>; my @array; my %hash; foreach my $_ (reverse @file) { chomp; next if ! m/^\s+\d/; s/^\s+//g; s/\s+$//g; s/\s+/,/g; my $key = join ',', ( split /,/ )[ 1, 2, 3 ]; # remove duplicates column b,c,d #push @array, $_ print $_, "\n" if ! $hash{$key}++; }