Hello,
I'm pretty new to Perl and I am running into a problem
that I think should be pretty easy to fix but I cannot
get the syntax right.
I am trying to write a script that will:
1. Open two files, one to be read from (call it file1)
and another to be written to (file2)
2. Both files will contain a list of entries (some
will be duplicates). If file1 contains an entry that
is not in file2, append it to file2. If the entry does
exist in file2, move on and check the next entry (in
file1).
Here is what I have so far:
open (FILE, ">>file2") || die "cannot open file2\n";
open (OIDFILE, "file1") || die "cannot open file1\n";
while (<OIDFILE>) {
$new_oid = $_;
while (<FILE>) {
if (!/$new_oid/) {
print FILE "$new_oid\n";
}
}
}
close (FILE) || die "cannot close file2";
close (OIDFILE) || die "cannot close file1";
I'm pretty sure the problem is with the if statement.
What is the best way to say in Perl "if this variable
does not exist in this file, write it. Otherwise, move
on and check the next entry" ? Right now, I'm not
getting any syntax errors, Perl is just politely
ignoring the print command.
Any assistance is greatly appreciated.
Jason
__________________________________________________
Do You Yahoo!?
Yahoo! Auctions - buy the things you want at great prices
http://auctions.yahoo.com/