in reply to re-initialize the hash
Maybe store your defaults separately:
my %hash_defaults = ('a'=>0 , 'e'=>0 , 'i'=>0 , 'o'=>0 , 'u'=> 0,); my %hash = %hash_defaults; ... # Reinitialize %hash = %hash_defaults;
... or restructure your loop code so that the initialization and reinitialization use the same code:
while (...) { my %hash = ('a'=>0 , 'e'=>0 , 'i'=>0 , 'o'=>0 , 'u'=> 0,); ... };
... or use local (but that only works for global variables, not lexical variables):
use vars '%hash'; %hash = ('a'=>0 , 'e'=>0 , 'i'=>0 , 'o'=>0 , 'u'=> 0,); ... do { local %hash = %hash; ... make some changes }; ... changes are forgotten
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: re-initialize the hash
by vennila (Novice) on Apr 01, 2010 at 08:38 UTC | |
by jethro (Monsignor) on Apr 01, 2010 at 08:56 UTC | |
by cdarke (Prior) on Apr 01, 2010 at 09:19 UTC | |
by vennila (Novice) on Apr 01, 2010 at 10:09 UTC |