in reply to anonymous subroutines assigning regexes to hash keys
I don't understand what you're trying to do (it might help if you explain what you intend to do with the hash of hahses once you've got it), but part of your problem is that your loops are in a bit of a mess. You're opening the file, and then for each of the 3 id values you're working though each line of the file (which won't work because the while (<INPUT>) eats the whole file on the first go when $id is 1234, leaving no more input for the other 2 id values). If you want to work through the file 3 times then you have to either close and open it again each time or reset the position with seek().
Each time around the while (<INPUT>) loop, you assign your hash of subs to the same thing, $hash{$id}. With a 100 line file, you'll assign to $hash{$id} 100 times for id 1234, and all but the last one will be lost.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: anonymous subroutines assigning regexes to hash keys
by donkeykong (Novice) on Jul 30, 2009 at 06:21 UTC |