in reply to Array to nested hash
Now, to test our subroutine:use List::Util qw( reduce ); sub array_to_nested_hash { reduce { scalar {$b,$a} } undef, reverse @_; }
Cheers,use Data::Dumper; $Data::Dumper::Terse = 1; $Data::Dumper::Indent = 0; print Dumper( array_to_nested_hash(1..5) ), "\n"; # {'1' => {'2' => {'3' => {'4' => {'5' => undef}}}}}
Tom Moertel : Blog / Talks / CPAN / LectroTest / PXSL / Coffee / Movie Rating Decoder
|
|---|