in reply to Comparing / Searching through Hashes

Compare to the answers to your question in Comparing arrays
  • Comment on Re: Comparing / Searching through Hashes

Replies are listed 'Best First'.
Re^2: Comparing / Searching through Hashes
by SayWhat?! (Novice) on Jun 28, 2012 at 12:48 UTC

    I have already done that and added the changes like suggested, but I'm still stuck. Someone called Athanasius suggested that I should start a new question in which I clarify what I would like my program to do. So that's what I did. :) I personally think this question explains in more detail than my previous one, though..

      Hello again, SayWhat?!,

      Good job on clarifying the question. I’m getting some idea of what you want to achieve. However, from your statement:

      I want the matching lines to be written to OutputFalseFriends.txt, and the non-matching lines to be written to OutputUnsortedWorldList.txt

      I would not expect the second output file to contain the line goed braaf, since this appears in both the input files. Is this a mistake, or am I missing something?

      (Incidentally, a large part of ‘programming’ is really sorting out requirements, independently of the actual code. This is just something we all need to get used to.)

      I think that, if you re-examine your code in light of your sample input, you will see that the requirements have evolved. For example, as RichardK observes, there are no commas, etc., to be cleaned up. Also, %hash is not being used for anything. Rather than fix your main loop — the loop beginning while (<BILWL>) — it will probably be easier if you re-think the logic of what you are doing and re-write this part from scratch.

      flexvault has given some excellent advice. In addition, it will help you if you include the line:

      use autodie;

      near the top of your script, as this will tell you when files cannot be opened, etc. Also, if you:

      use Data::Dumper;

      this will make the debugging task easier. (Data::Dumper is a core module, so it will already be in your Perl installation. See http://perldoc.perl.org/Data/Dumper.html for details.) For example, you can print the contents of %falsef with just:

      print Dumper(\%falsef);

      You’re making progress!

      Athanasius <°(((><contra mundum

      A reply falls below the community's threshold of quality. You may see it by logging in.