...

View Full Version : Difficult problem...



errodr
07-23-2002, 06:52 AM
I have a difficult problem, which I'm sure someone here will be

able to figure out quickly.

Problem:

I have two files (.txt) each file contains a list of page titles.

What I need to do is take File A (the Master list) remove from

it page titles that appear in File B (the a page title subset).

Basically I need to take the page titles that appear in File B

and remove those titles from File A.

I have tried this, and it simply spits out File A with no changes.
--------------------------------------------------------------------------------
Code
--------------------------------------------------------------------------------


open(FILEB,"FileB.txt")||die;
while(<FILEB>){
$file1hash{$_}=1;
}

close(FILEB);

open(OUTPUTFILE,">new_report.txt")||die;

open(FILEA,"FileA.txt")||die;

while(<FILEA>){
print OUTPUTFILE $_ unless defined($file1hash{$_});
}

close(FILEA);

close(OUTPUTFILE);

--------------------------------------------------------------------------------

Thanks a lot...

pager
08-09-2002, 04:24 AM
- what a b/buster.

You didn't chop the lf's out of your hash keys.

%file1hash = ();
open(FILEB,"fileb.txt")||die;
while(<FILEB>){
chop;
$file1hash{"$_"} = 1;
}
close (FILEB);

open(OUTPUTFILE,">newreport.txt")||die;

open(FILEA,"filea.txt")||die;
while(<FILEA>){
$temp=$_;
chop;
print OUTPUTFILE $temp unless defined($file1hash{"$_"});
}
close(FILEA);

close(OUTPUTFILE);

errodr
08-09-2002, 04:37 AM
Yeah...

Once I stripped the files clean, the script worked perfectly...

I always forget those lf's...


Thanks...



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum