in reply to How to delete lines with similar data
However, apart from gellyfish, they also seem to have missed the point. ;-) To avoid duplicates in "NEWFILE" you could do something like the following:
#!/usr/local/bin/perl -w use strict; open REGFILE, "projects.dat" or die "Error message here: $!\n"; open NEWFILE, "+>>subscribe.dat" or die "Error message here: $!\n"; # Rewind the file for reading seek(NEWFILE, 0, 0); # Store all lines in NEWFILE in %seen using a hash slice my %seen; @seen{<NEWFILE>} = undef; while (<REGFILE>) { if (not exists $seen{$_}) { $seen{$_} = undef; # Do your split etc here print NEWFILE $_; } } close (NEWFILE); close (REGFILE);
--
John.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: How to delete lines with similar data
by Jeffro Tull (Novice) on Feb 05, 2002 at 14:21 UTC |