Forum Moderators: coopster & phranque

Message Too Old, No Replies

Perl commands from template input file

         

jwzumwalt

7:17 pm on Dec 25, 2007 (gmt 0)

10+ Year Member



If I hard code the following in a cgi script it works...

my $timestamp = localtime time;
print <html><body>$timestamp</body></html>;

However, the $timestamp will not work if the same code is imported from a template file - it is printed out as text.

How do I get Perl to interpret code from a template file as literal (during a print command)?
.
Thanks - JZ

perl_diver

10:00 pm on Dec 25, 2007 (gmt 0)

10+ Year Member



The point of using templates is to seperate code from format/display so putting code in a template is the wrong approach. You import the variable to the template from your code.

Dabrowski

12:27 pm on Dec 27, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



7:17 pm on Dec. 25, 2007

I can't believe it, you actually posted on christmas day. I knew someone had to!

jwzumwalt

10:53 pm on Dec 28, 2007 (gmt 0)

10+ Year Member



Well... I'm a retired firefighter of 21 years. I guess that job got me to look at every day as a workday :-)

jz

phranque

6:28 am on Dec 29, 2007 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



he actually joined on christmas.

welcome to WebmasterWorld [webmasterworld.com], jz!

you could look into embperl [perl.apache.org] or Mason [masonhq.com] or the Text::Template perl module [search.cpan.org].