On Mon, 2005-03-28 at 15:06, Zhuang Li wrote:
> Hi, given an array: @a = ('E1', 'E2', ..., 'En');
>
>
>
> Is there an easy way, hopefully one liner, to do the following without a
> loop? If not, will Perl support this in Perl 6?
>
>
>
> $hash->{E1}->{E2}->...->{En} = 1;
use Data::Dumper;
my @x = qw/a b c d e/;
my $h = {};
my $s = join '}->{',@x;
eval '$h->{'.$s.'}=1';
print Dumper $h;
You asked this on a "fun with Perl" mailing list, but something about
your tone implies that you think this may be a useful, good thing to do
rather than simply fun. Please know that I intend this only for fun.
:-)
Cheers,
Jeff