my @array = qw /a b c d e f/; my $hash = 1; my $tmp; ($tmp->{pop @array}, $hash, $tmp) = ($hash, $tmp, undef) while @array;