
perlkid
stranger
Mar 3, 2000, 6:48 PM
Post #1 of 4
(378 views)
|
|
Fighting Duplicates
|
Can't Post
|
|
Hi guys, I'm trying to get this code to work for me but it seems like no matter what I do I can't get it to stop writing to the file when It is already in there. Here is the code <BLOCKQUOTE><font size="1" face="Arial,Helvetica,sans serif">code:</font><HR> foreach $element (@results) { ($field1, $field2, $field3, $field4, $field5, $field6, $field7, $field8, $field9, $field10) = split(/\|/,$element); open(c,">>/path/to/$data.db"); print c "$field3|$field5|$ENV{'MY_QUERY'}|$field4| ||\n"; close(c); open(k,"+</path/to/$data2.db"); @all = <k>; foreach $line (@all) { (@fields) = split(/\|/,$line); } for (@fields) { if ($fields[0] eq "$field1") {} else { $pr = "ok"; } }} if ($pr) { print k "$ENV{'MY_QUERY'}|\n"; } close (k); </pre><HR></BLOCKQUOTE> It still prints duplicates. What do you you think is wrong? Thanks for the help, perlkid
|