in reply to Array to nested hash

This is my best guess. =)
#!/usr/bin/perl use strict; use warnings; use Data::Dumper; my @a = qw(1 2 3 4 5 6 7 8 9); my $h = {}; my $t = $h; map { ($t = $t->{$_} = ($_ eq $a[-1])? undef : {}) } @a; print Dumper($h);

But as always, use at your own risk.

Cheers!
--habit