Home: Perl Programming Help: DBI:
Post deleted by appetitto



appetitto
Novice

Aug 15, 2012, 7:46 AM


Views: 26672
Post deleted by appetitto

 


FishMonger
Veteran / Moderator

Aug 15, 2012, 8:30 AM


Views: 26666
Re: [appetitto] Cannot update record in file with Dump module

There are several very questionable aspects to your code. One is your use of eval.

You should add a couple print statements to the loop to see how it progresses thru the file.

The starting point would be to add these 2 pragmas and fix the issues that they point out.

Code
use strict; 
use warnings;


Can you post your data file so I can see what you're attempting to accomplish?


appetitto
Novice

Aug 15, 2012, 8:47 AM


Views: 26660
Post deleted by appetitto

 


FishMonger
Veteran / Moderator

Aug 15, 2012, 9:02 AM


Views: 26655
Re: [appetitto] Cannot update record in file with Dump module

Those errors mean that you need to declare the vars, which is done with the 'my' keyword like you did on the other vars.

So, if I understand correctly, your data file is a config file containing vars that you need to use in the script. If so, then instead of reading in the file and using eval like that, you can load the file with a require or do statement.

Code
require $megalithFile;

or

Code
do $megalithFile;


However, a much better solution would be to use a standard config file and parse that file rather than executing code via eval. There are many config parser modules on cpan which make this task very easy and safe. Using eval like that is very insecure and dangerous.