my @nc; my %seen; while (<$fh>) { chomp; push @nc, $_ if !$seen{$_}++; } #### my @nc; my $last; while (<$fh>) { chomp; push @nc, $last = $_ if !defined($last) || $last ne $_; }