in reply to compare two text file line by line, how to optimise

This code could be considerably shortened, and made easier to read, as well as faster, if you re-do it in idomatic perl.

To get you started in that direction:

* Use meaningful variable names
* Error check each file open by adding open(...) or die "Could not open <filename>:$!";
* Do not repeatedly loop over the same arrays
    Do all necessary processing in a single loop over the array.
* Use appropriate data structures: Use a hash for word lookups .
* Use subroutines for repeated code.

In addition, for questions to PM, be clear on what the inputs, and expected outputs look like. Also, a clear problem statement, and a polite request would probably induce someone to write it for you, since we have seen that you have put effort into doing this.

        "Think of how stupid the average person is, and realize half of them are stupider than that." - George Carlin

  • Comment on Re: compare two text file line by line, how to optimise

Replies are listed 'Best First'.
Re^2: compare two text file line by line, how to optimise
by thespirit (Novice) on Feb 26, 2016 at 11:29 UTC
    Hi Sorry if my message diturbed you! Because in other forum, the moderator don't accept terms like hello, hi. I was wondering that also in this formum they directly want the subject and the question Regards
      "Hello", "Hi" and other greetings are acceptable, but not necessary, as a part of the message content.

      Avoid putting them in the SUBJECT, because they distract at a place where you need to be concise.

              "Think of how stupid the average person is, and realize half of them are stupider than that." - George Carlin