use strict; use warnings; my $passwdfile = "d.txt"; my %seen = (); { local @ARGV = ($passwdfile); local $^I = '.bac'; while(<>){ $_ =~ s/^\s+//; $seen{$_}++; next if $seen{$_} > 1; print; } } print "finished"; #### 5 5 5 5 5 6 55 6 66 5 5 5 5 #### 5 5 6 55 66