Hi Magnolia25,
Note that your code contains some errors that prevent it from compiling. I'm going to assume you copied the code you showed out of a larger program and that you've actually got use warnings; use strict; and the missing variable declarations. In the future, please try to provide code that compiles (SSCCE).
First, in last if !line;, you're missing the $ sigil from $line.
Second, note how you've got a comma in (split(/;/, $line)),[1,0]. This is creating several values: the return values of split, plus the anonymous array [1,0]. What you probably meant is (split...)[1,0], which returns a list consisting of the second return value of split followed by the first return value of the split.
If you fix these issues, you've still got a conceptual problem. The way I understand it, you're trying to store a hash with multiple values per key. One way to do this is with a "hash of arrays" or "hash of hashes", which are described with lots of example code in perldsc.
Because this sounds very much like a homework assignment, I'm reluctant to do too much of your work for you :-) However, if you look at perlreftut and perldsc, I hope it will become more clear how you can accomplish your tasks:
* For parsing files like this, it really would be best to use a module like Text::CSV.
Your "Step 2" sounds very much like "Step 1", except with different columns. If you also need to filter the "Step 2" input file, I would suggest that you store the first column from your "Step 1" input file in a hash, and when you're parsing your "Step 2" input file, seeing if that value exists in the hash you created.
Hope this helps,
-- Hauke D
In reply to Re: Print hash keys and lookup the keys for values in another filr
by haukex
in thread Print hash keys and lookup the keys for values in another filr
by Magnolia25
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |