use strict; use warnings; use Data::Dumper; my $index = q{ 1 => 'foo', 2 => 'bar', 3 => 'baz', }; my %index3 = eval $index; print Dumper \%index3;