There is a lot of good advice in the previous posts and I think that you should take it into account.
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.
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.