in reply to Accessing variables in an external hash without eval
Output:use strict; use warnings; use Data::Dumper; my %hash; my $loadedFile = do {local $/=undef; <DATA>}; { no strict; eval ($loadedFile); if ($@) {print 'eval error:'.$@."\n"; } } my $hashData = $hash{Scope}{model}; my @dereferencedData = @$hashData; print "Data: \n", Dumper (\@dereferencedData), "\n"; __DATA__ %hash = ( #scope changes Scope => { model => [ 'data I need', 'another row of needed data', 'more data I need' ] }, IrreleventScope =>{ a=>'b' } );
Data: $VAR1 = [ 'data I need', 'another row of needed data', 'more data I need' ];
Once it hits the fan, the only rational choice is to sweep it up, package it, and sell it as fertilizer.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Accessing variables in an external hash without eval
by victorz22 (Sexton) on May 17, 2017 at 05:08 UTC | |
by NetWallah (Canon) on May 17, 2017 at 13:52 UTC |