in reply to hash initialisation
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
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re (tilly) 2: hash initialisation
by tilly (Archbishop) on Mar 27, 2001 at 06:34 UTC | |
|
Re: Re: hash initialisation
by agoth (Chaplain) on Mar 26, 2001 at 19:30 UTC |