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";