in reply to re-initialize the hash
my %hash= initvalues(); ... %hash= initvalues(); ... sub initvalues { return ('a'=>0, ...); }
or with sideffects
my %hash; inithash(\%hash); .... inithash(\%hash); ... sub inithash { my $h= shift; $_[0]= { 'a'=>0, ... }; #note the curled braces #CORRECTED %$h= ( 'a'=>0, ... ); #alternative to the previous line }
UPDATE: First alternative in the inithash sub didn't work because it was changing the pointer, now it should work
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: re-initialize the hash
by AnomalousMonk (Archbishop) on Apr 01, 2010 at 09:07 UTC |