Hello Bas,
Thursday, August 23, 2001, Bas Bloemsaat <[EMAIL PROTECTED]> wrote:
BB> I've got this code:
BB> #Example of generated code. I have little influence over the actual code in
BB> the variable. It's generated from a template.
BB> $generatedCode = '$test = "some result"; print "test is: $test";';
open MYFILE, ">>somefile";
BB> select(MYFILE);
BB> my $testvar = eval "$generatedCode";
BB> select(STDOUT);
BB> close MYFILE;
BB> this prints the result of the generated code in a file called somefile. Is
BB> there any way in which I can store the output from the
BB> eval "$generatedCode";
BB> in a variable, be it a string or an array, instead of in a file? I have to
BB> do this a lot , and having a file in between slows the code quite a bit.
i'm not sure, that have correctly understand you.
may be you need this?
$generatedCode = '$test = "some result"; print "test is: $test";';
$generatedCode =~ s/print /return /;
my $testvar = eval "$generatedCode";
print "testvar=$testvar";
Best wishes,
Maxim mailto:[EMAIL PROTECTED]
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]