use strict; my %seen; while(){ chomp; my @parts = split /-/; print $_,"\n" if $parts[0] eq 'LA' && !$seen{$parts[0]-$parts[1]}++; } __DATA__ LA-1-00 CON-1-0 LA-2-01 LA-03-2 LA-03-02