|Problems? Is your data what you think it is?|
frequency strings 2 filesby philbertcheese86 (Initiate)
|on Jul 05, 2012 at 22:48 UTC||Need Help??|
philbertcheese86 has asked for the
wisdom of the Perl Monks concerning the following question:
Hi I'm new to perl (2 weeks). I'm understanding everything in my textbook just fine, but the projects our teacher gives us are way harder than anything we've covered. He wants us to do the following.
Write a Perl program that will read from two files specified on the command line. Both files will be a list of positive integers (one entry per line) and terminated with a zero. Your program should (ignoring the zeros) output, in the given order, each of the numbers in the second file followed by a single space and then the number of times that value appears in the first file.
If testfile1 has (5 3 2 7 5 4 3 2 5 0) in it, and testfile2 has (5 2 3 1 0) running the program will look like
Here's my attempt at a solution
I get no error messages. I really can't emphasize enough that the 13 pages on hashes in the llama book do not address anything nearly as complex as searching through every key of a hash AND comparing those keys to each element of an array. More specifically several things are not done to the same hash. There is an example that does this:
so I have a similar method checking to see if the keys of my hash match each value in an array. I appreciate the solutions provided by others, but what is wrong with my solution?