#!/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);
In reply to Re: Array to nested hash
by habit_forming
in thread Array to nested hash
by amw1
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |