in reply to initialize all values in a hash
If you know the keys in advance, it's relatively easy:
use Data::Dumper; my %hash = map { $_ => 60; } qw(foo bar baz); print Dumper \%hash;
If you don't... well... that's not how hashes work. You could do it with a tied hash, but I can't find a module that does this on CPAN, so you'd need to do it yourself.
But it would be better to modify the code that reads from the hash so that before it reads from the hash, it checks whether that value exists in the hash, and substitutes 60 if not.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: initialize all values in a hash
by tobyink (Canon) on May 18, 2012 at 13:58 UTC | |
by DrHyde (Prior) on May 18, 2012 at 14:03 UTC | |
by tobyink (Canon) on May 18, 2012 at 14:27 UTC | |
by DrHyde (Prior) on May 18, 2012 at 15:35 UTC | |
by tobyink (Canon) on May 18, 2012 at 16:49 UTC | |
|
Re^2: initialize all values in a hash
by AWallBuilder (Beadle) on May 18, 2012 at 11:02 UTC |