<div dir="ltr"><span style="font-family: courier new,monospace;">I've got one program that generates a hash and then uses Data::Dump to write this structure to a text file:</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">printf FILE Data::Dumper->Dump(\%fields],['fields']);</span><br style="font-family: courier new,monospace;"><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">The resulting file contains this:</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">--- begin contents ---</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">$fields = {</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> 'FIELD1' => {</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> FIRSTNAME => 'Joe'</span>,<br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> LASTNAME => 'Smith'</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> }</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">}</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">--- end contents ---</span><br style="font-family: courier new,monospace;">
<br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">Unfortunately, when I try to use "eval" to pull this hash variable construct into a second running process:</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">--- begin contents ---</span><br style="font-family: courier new,monospace;" clear="all"><span style="font-family: courier new,monospace;">sub retrieve_fields {<br> my ( $file )=@_;<br>
my %fields;<br> open(FILE, $file)<br> {<br> local $/;<br> eval <FILE>;<br> }<br> return %fields;<br>}<br></span><span style="font-family: courier new,monospace;">--- end contents ---</span><br style="font-family: courier new,monospace;" clear="all">
<br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">When I run the second program, perl dies on the "eval" line with this error:</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">Variable "$fields" is not imported at (eval 125)[testprog.pl:33] line 1, <FILE> chunk 1.</span><br style="font-family: courier new,monospace;"><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">The odd thing is if the Data::Dump file is changed to "%fields = ( ... )" then the "eval" works!?!?</span><br style="font-family: courier new,monospace;">
<br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">I've found some notes about using "our" and "use vars qw(...)". Anyone else have any suggestions?</span><br style="font-family: courier new,monospace;">
<br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">Dan</span><br style="font-family: courier new,monospace;"><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">-- </span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">"Quis custodiet ipsos custodes?" (Who can watch the watchmen?) -- from the Satires of Juvenal</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">"I do not fear computers, I fear the lack of them." -- Isaac Asimov (Author)</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">** *** ***** ******* *********** *************</span><br style="font-family: courier new,monospace;">
</div>