in reply to Case of autovivification
It would be really bad if Perl started treating the contents of variables as Perl code. Use Data::Diver.
#!/usr/bin/perl use strict; use warnings; use Data::Diver qw( DiveVal ); use Data::Dumper qw( Dumper ); my %hash; my @keys = ( 5, 6 ); # $hash{root}...{2} = 'b'; DiveVal( \%hash, map \$_, 'root', @keys, 2 ) = 'b'; print Dumper(\%hash);
Tip: For best results, always pass a scalar to Dumper. If you want to dump an array or hash, pass a reference to it.
|
|---|