newbie00 has asked for the wisdom of the Perl Monks concerning the following question:
Hello.
Is it possible to execute the following code versus display it as text?
>>> Scenario: <<<
In the .pm file,
Template code is stored in the '$template_file' var which contains a place holder called {PERL_CODE}
my $c = ... my $perlcode = 'print $c->get_html( 'some text' );'; $template_file =~ s/{PERL_CODE}/$perlcode/;
I tried this, but then had to escape the $c in $perlcode otherwise the value of $c is replaced:
my $perlcode = 'print \$c->get_html( 'some text' );';The issue is, instead of the print function being executed, the entire statement was printed literally as a text string (which was somewhat expected).
Is there a way to execute the code instead?
Thanks.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Possible? String Search, Replace & Execute Code
by Anonymous Monk on Jul 09, 2010 at 06:27 UTC | |
by newbie00 (Beadle) on Jul 09, 2010 at 06:55 UTC | |
by cdarke (Prior) on Jul 09, 2010 at 07:04 UTC | |
by Anonymous Monk on Jul 09, 2010 at 07:00 UTC | |
by newbie00 (Beadle) on Jul 09, 2010 at 08:23 UTC | |
by newbie00 (Beadle) on Jul 17, 2010 at 09:03 UTC |