in reply to Array to hash refs

my solution:
use strict; my @array = qw/a b c d e f/; my $t = my $hashref = {}; while (@array) { $t = $t->{ shift @array } = @array>1 ? {} : 1 };

Replies are listed 'Best First'.
Re: Re: Array to hash refs
by Anonymous Monk on Aug 14, 2002 at 11:27 UTC
    Eval man!
    my @array = qw/a b c d/;
    
    my $ref = {};
    
    $code = '$ref->{'.join('}->{', @array).'} = 1;';
    
    eval $code;
    
    use Data::Dumper;
    print Dumper($ref);