in reply to Re: to avoid redundacy in a file
in thread to avoid redundacy in a file
You can do it in one shot, so you might as well. Note that this code eliminates all duplicate lines, not just repeated ones. If you want to just ditch repeats, use this:my %seen; while (<>) { next if ($seen{$_}++); print; }
Thus lines "A A A B B B A A C C" will be "A B A C" not "A B C" as in the previous bit.my $last; while (<>) { next if ($_ eq $last); $last = $_; print; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: to avoid redundacy in a file
by Aristotle (Chancellor) on Jul 15, 2002 at 13:55 UTC | |
by tadman (Prior) on Jul 15, 2002 at 19:06 UTC |