in reply to Re: Read file in a hash and compare the 'values' from file 2
in thread Read file in a hash and compare the 'values' from file 2

Thanks for the code, Now I got my keys and values from file 1 in $outputFile. what I need now is to open File2:
#file2 abcdef hijkl mnop qrstuv wxyzabc
compare it one by one with the 'values' of $outputFile and print the key of $outputFile corresponding to the values matched in file2. so that the output wud be like:
>1 abcdef >4 xyzabc . . etc

Replies are listed 'Best First'.
Re^3: Read file in a hash and compare the 'values' from file 2
by Anonymous Monk on Jul 05, 2011 at 13:44 UTC

    Thanks for the code, Now I got my keys and va... what I need now is to open ...

    My code merely demonstrates how your code fragment doesn't work. The hash only contains one key value pair.

    Its an example of runnable code.

    You claim %hash is correctly populated? Then you need to show that code, and make sure it is runnable in a similar fashion as I did.

    If you want to start with my code, you need to edit the program until %hash is correctly populated, while at the same time changing the function/variable names to be meaningful. Use Data::Dumper at various points to see where your assumptions don't match, its part of the Basic debugging checklist.

    $outputFile doesn't make sense as a variable name for a file that you wish to read from.

    Similarly NotDemoMeaningfulName and Boobly aren't great function names.

    See Is PerlMonks a good place to get answers for homework?