in reply to i thought i understood shift...

Don't use something that alters @array on the left side of the same assignment as accessing @array on the right. Order of execution is not guaranteed. And your taking a reference to a dereference of a reference made from a list constructed from something that was already a list (whew!) has me dizzy.

Also, learn to use the shortcuts of CGI.pm. Even Lincoln avoids the object-oriented form for short programs.

Some code:

my @array = qw(1 2 3 4 5 6 7 8 9); my %test; my $where = shift @array; $test{$where} = [splice @array, 0, 2]; ...
Don't put the shift in the same expresssion as the splice. Order of execution not guaranteed. One other way to do it:
$test{$_} = [splice @array, 0, 2] for shift @array;
which is nice because it eliminates the intermediate variable. Even weirder:
$_ = [splice @array, 0, 2] for $test{shift @array};
which still works because we know the shift has to happen before the splice.

-- Randal L. Schwartz, Perl hacker