The more I thought about it, Data::Dumper has little to do with the exact problem I am having, but the way it works constricts me to using particular steps in my script. Data::Dumper is a utility to build simple text based databases. Basically what it does is take input data, escapes anything that is meaningful to perl ($,@,etc), and puts it into "variable1 = data1; variable2 = data2; etc" format, where you set up the variable name (and the data). You can then write this information to a file for storage. Then you have Perl read in this file, and eval each line to get your data back into your script.
Normally, or at least for the other times that I have used Data::Dumper, the variables have been known, so I declare them with "use vars qw()". For this script, though, I will be working on different templates, and each template will have it's own unique variables. So when I am reading the data in from the dumper file, I don't know what it is until I read it. This causes a problem with "use strict" since it wants variables predeclared. So far a good suggestion has been to turn off "use strict" for the block of code that reads in the data (thank you Jenda Krynicky). Another idea of mine was to have a known variable name, that contains the names of all the other variables, so that I can predeclare them before I read them in. This seems bulky and harder to maintain. Are there any other ideas? Has the problem been described well? Thanks for your time, =-= Robert Thompson On Tue, Dec 11, 2001 at 10:47:42AM +0000, Daniel Gardner wrote: > Tuesday, December 11, 2001, 1:09:06 AM, Robert Thompson wrote: > > > I am using Data:Dumper in a script and am running into a problem with "use >strict" and eval. Basically the conundrum is that the data I will be loading from the >Data::Dumper file is going > > to be based off input to the final script, so it may not be the same for each run >of the script. There will be many dumper files that have different variables. I >cannot predeclare them for "use > > strict" since I won't know what they are until the eval. > > > The only work around is to turn off use strict, but I would like to >continue using it. Is there a way, either with Data:Dumper, or something else to get >this to work? > > > Here is the snippet of code and some source files, so if one is confused >hopefully this will explain: > > > eval shift(@wholetemplatefile); # define $datadumperfile. > > eval shift(@wholetemplatefile); # define $outfile. > > shift(@wholetemplatefile); # Get rid of the divider. > > > # Get the Data::Dumper information. > > open (READ_DD, $datadumperfile); > > while(<READ_DD>) { > > eval $_; > > } > > close(READ_DD); > > > it doesn't look like you got any replies. perhaps you could indulge > us, try explaining your problem again assuming we don't know what > Data::Dumper is. it might help... > > > -- > Best regards, > Daniel [EMAIL PROTECTED] > -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]