marto9 has asked for the wisdom of the Perl Monks concerning the following question:
Input: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";
Output:5 5 5 5 5 6 55 6 66 5 5 5 5
I know it can be done with regex, but I'm a real beginner in perl and regex still looks very hard to me. Thx in advance5 5 6 55 66
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Duplicate lines with spaces, tabs...
by moritz (Cardinal) on Jul 17, 2008 at 11:50 UTC | |
|
Re: Duplicate lines with spaces, tabs...
by pjotrik (Friar) on Jul 17, 2008 at 11:52 UTC | |
|
Re: Duplicate lines with spaces, tabs...
by psini (Deacon) on Jul 17, 2008 at 11:56 UTC | |
|
Re: Duplicate lines with spaces, tabs...
by apl (Monsignor) on Jul 17, 2008 at 12:10 UTC | |
|
Re: Duplicate lines with spaces, tabs...
by marto9 (Beadle) on Jul 17, 2008 at 13:00 UTC | |
by cdarke (Prior) on Jul 17, 2008 at 13:09 UTC | |
by jethro (Monsignor) on Jul 17, 2008 at 13:43 UTC | |
by marto9 (Beadle) on Jul 17, 2008 at 13:56 UTC | |
by massa (Hermit) on Jul 17, 2008 at 14:23 UTC | |
by marto9 (Beadle) on Jul 17, 2008 at 15:51 UTC |