Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re^2: compare two files and print the differences of file 2 in a third file

by hopper (Novice)
on Jun 15, 2017 at 20:45 UTC ( [id://1192891]=note: print w/replies, xml ) Need Help??


in reply to Re: compare two files and print the differences of file 2 in a third file
in thread compare two files and print the differences of file 2 in a third file

Thanks for taking time to take look at my code.
I think you misunderstand my issues. The issues is that I have two files and each files has the multiple sections, and each section contents the description of it. The problem I am want to do is to compare two files and only print out the sections and subsection within that are not in file1 and save to the third file. So far, my code print out the diff(file2)of the sections that are not in file1 but it does not print out the subsections that belongs to the section.

Please help me figure out what is the issues with my code.
Thanks so much in advance.

  • Comment on Re^2: compare two files and print the differences of file 2 in a third file

Replies are listed 'Best First'.
Re^3: compare two files and print the differences of file 2 in a third file
by dbander (Scribe) on Jun 16, 2017 at 13:43 UTC

    Your issue is that you are not reading GOODFILEproperly.

    You thanked me for taking the time to look at your code.
    I will now thank you to take the time to actually try the answer I gave you.

    Click on the spoiler link below to see what the problem is.

    I added a chompand printstatement after each of the while()statements, which is what I asked you to do.

    Here's what I get when I run the modified version of your script:

    Starting script Enter the GOOD file: GoodFile.txt Enter the BAD file: BadFile.txt GOODFILE line: 'GOODFILE' BADFILE line: 'Amimal, cat, 1, 4, YELLOW HAIR 3, HIGH 'this is a catt +t 1' BADFILE line: 'This section is the description of the animal bla bla +lbas.....bla bla lbas.....' BADFILE line: 'Amimal, cat, 3, 4, YELLOW LEG 3, HIGH 'this is a cattt + 1' BADFILE line: 'This section is the description of the animal bla bla +lbas.....bla bla lbas blaaaal........'

    Look closely at the line which shows what data you are "reading" from GOODFILE.
    Do you still think it is me who doesn't understand your problem?

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1192891]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others examining the Monastery: (7)
As of 2024-04-19 08:37 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found