Gossamer Forum
Home : General : Perl Programming :

Including html files in a cgi script, how??

Quote Reply
Including html files in a cgi script, how??
Ive searched the forum, found a couple of threads on the matter and tried them and it doesnt work for me and i dunno why.

this is the exact code i have in my script

#!/usr/bin/perl

open (INC, "/web/myurl/test.htm") or die "Can't open: $!";
$include = ("", <INC> );
close INC;

print "Content-type:text/html\n\n";
print $include;
print "<html><head><title>Test Page</title></head>\n";
print "<body>\n";
print "<h2>Hello, world!</h2>\n";
print "</body></html>\n";

The script will print 'Hello, world!' but it wont print the contents of the file test.htm any where.

Anyone give me any advice on fixing this?
Quote Reply
Re: [TheIceman] Including html files in a cgi script, how?? In reply to
dont worry, i figured it out, all i did was replace the $ with a @ and all was fine.

later...
Quote Reply
Re: [TheIceman] Including html files in a cgi script, how?? In reply to
>>
$include = ("", <INC> );
<<

You should actually be using:

$include = join("", <INC> );

However read() or do{} are both better.
Quote Reply
Re: [Paul] Including html files in a cgi script, how?? In reply to
yeah your right, i left out the 'Join' i put that in and made the @ into $ again and it worked fine.

thanks.