davidfilmer has asked for the wisdom of the Perl Monks concerning the following question:
To my unenlightened eyes, my eval for %index2 is functionally and syntactically equivalent to the creation of %index1. I humbly approach the Oracles for wisdom.use Data::Dumper; my %index1 = ( 1 => 'foo', 2 => 'bar', 3 => 'baz', ); print Dumper \%index1; #looks as expected my $index = q{ 1 => 'foo', 2 => 'bar', 3 => 'baz', }; print Dumper $index; #looks as expected my %index2; eval{ %index2 = ( $index ) }; print Dumper \%index2; #hash has one key ($index) and value undef __END__
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Using eval to create a hash
by AnomalousMonk (Archbishop) on Jun 01, 2015 at 02:14 UTC | |
by Anonymous Monk on Jun 01, 2015 at 10:14 UTC | |
|
Re: Using eval to create a hash
by LanX (Saint) on Jun 01, 2015 at 08:07 UTC | |
|
Re: Using eval to create a hash
by Discipulus (Canon) on Jun 01, 2015 at 07:56 UTC | |
|
Re: Using eval to create a hash
by BillKSmith (Monsignor) on Jun 01, 2015 at 12:38 UTC | |
|
Re: Using eval to create a hash
by Anonymous Monk on Jun 01, 2015 at 02:27 UTC |