Gossamer Forum
Home : Products : Links 2.0 : Discussions :

Re: perl code in template files?

Quote Reply
Re: perl code in template files? In reply to
Ok. I can't access the server until the FTP is up on monday, so I'll just ask if this is going to work:

- I "enhanched" the template.pm
- I added this code to site_html_templates.pl:
Code:
sub add_counter {

if ( open (HITS_RD, "d:/webserver/cosmo-web/site/counter/count.txt") ) {
$hits = <HITS_RD>;
close HITS_RD;

if ( open (HITS_WR, ">d:/webserver/cosmo-web/site/counter/count.txt") ) {
print HITS_WR ++$hits;
close HITS_WR;
}
}

$counter1 = $hits + 68349;
$counter2 = $hits + 120000;

$cosmorand = rand;
}
I added &add_counter; below the &html_print_headers; line in all subs that generate the CGI-pages.

Now, can I add things like:
Code:
counter 1 is <%counter1%>, and <%cosmorand%> is a random number
to my CGI template files (add.html, etc.)? Or have I misunderstood?

Subject Author Views Date
Thread perl code in template files? cosmo 1276 Jan 23, 2001, 8:23 AM
Thread Re: perl code in template files?
Stealth 1222 Jan 23, 2001, 12:56 PM
Thread Re: perl code in template files?
cosmo 1195 Jan 24, 2001, 6:33 AM
Thread Re: perl code in template files?
Stealth 1208 Jan 24, 2001, 8:18 AM
Thread Re: perl code in template files?
cosmo 1200 Jan 24, 2001, 8:46 AM
Thread Re: perl code in template files?
Stealth 1193 Jan 24, 2001, 11:02 AM
Post Re: perl code in template files?
cosmo 1191 Jan 24, 2001, 3:39 PM