Yes, you are :)
There are a couple of optimisations you can make here. Firstly, you have may constructs like:
for ('something' .. 'something else') { my $var = $_;
where you can use:
for my $var ('something' .. 'something else') {
Secondly, and more importantly, at each level you initialise the elements to empty lists, with code like:
$bucket{$x}{$y} = ();
But on the next level down ,you overwrite it with an reference to a hash. The initial assignment is unnecessary.
In fact, you can simply the whole thing to:
--for my $month ('02'..'03') { for my $day ('00' .. $mons{$month}) { for my $hour ('00' .. '24') { for my $minute ('00' .. '59') { $bucket{$month}{$day}{$hour}{$minute} = [0,0]; } } } }
"Perl makes the fun jobs fun
and the boring jobs bearable" - me
In reply to Re: hash initialisation
by davorg
in thread hash initialisation
by agoth
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |