%hash = ();
would work, but it's not. And yes, I am using strict. The code is a bit long, but an abridged version is:
use strict;
use warnings;
my %hash;
my @sets = qw(set_a set_b);
foreach my $set ( @sets ) {
&find_start($set); #defines start and end points to grab data
&fill_hash(); # fill 'er up
&print_hash(); #print out
&clean_hash(); #clean it out
}
The &find_start() looks throught the 6000 lines of text, and decides which line to start grabbing data, and which line to stopt at, based on the value of $set. I thought maybe I was grabbing the wrong stuff, but everything "adds up". Pun intended. | [reply] [d/l] [select] |
Are you absolutely certain those subs are using the same %hash as is declared there? (Try sticking some print \%hash; statements in the foreach loop and at the beginning of the *_hash subs.) Are the subs in the same source? Do you have another my %hash statement? You aren't tweaking the readonly flag on %hash, are you?
| [reply] [d/l] |
I'm very sure there's no other hash references in there. I double checked that. I don't know anything about read only flags, so I suspect it's not that.
I'm going over everything again, and haev even sucked a colleague in, but I've stumped him as well.
Grrrrr..
| [reply] |
| [reply] |
Your code snippet is too short. I appreciate your desire to be brief, but we're missing some criticial bits, chief of which is the contents of the clean_hash subroutine.
If I had to rely on intuition, though, I'd bet you were redeclaring your hash in clean_hash. This isn't a good or bad thing, entirely, because you should delete this call altogether, and replace it with the %hash=() that people have advised it'll get rid of your scoping error altogether. Wrapping such a trivial line of code in a sub makes baby Jesus cry.
| [reply] [d/l] |