As kevbot said your example is flawed.
This works for me
Resultuse strict; use warnings; use Data::Dumper; my %hash; my $loadedFile = join "", <DATA>; { no strict; eval ($loadedFile); if ($@) {print 'eval error:'.$@."\n"; } } my @hashData = $hash{Scope}{model}; my @dereferencedData; foreach my $line (@hashData){ @dereferencedData = @$line; } print "Data: \n"; print Dumper @dereferencedData; print "\n"; __DATA__ %hash = ( #scope changes Scope => { model => [ 1,2,3,4,5,6 ] }, IrreleventScope =>{ a=>'b' } ) ;
Notice the addition of a semi to the end of your example dataData: $VAR1 = 1; $VAR2 = 2; $VAR3 = 3; $VAR4 = 4; $VAR5 = 5; $VAR6 = 6;
In reply to Re: Accessing variables in an external hash without eval
by huck
in thread Accessing variables in an external hash without eval
by victorz22
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |