Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New to the CF scene
    Join Date
    Jul 2002
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Angry Difficult problem...

    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...

  • #2
    New Coder
    Join Date
    Aug 2002
    Posts
    24
    Thanks
    0
    Thanked 0 Times in 0 Posts
    - 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);

  • #3
    New to the CF scene
    Join Date
    Jul 2002
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Yeah...

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

    I always forget those lf's...


    Thanks...


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •