CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Beginner:
Reading HTML from a file with Perl

 



Zippy
New User

Aug 7, 2002, 1:28 AM

Post #1 of 4 (512 views)
Reading HTML from a file with Perl Can't Post

Im attempting to write some CGI that will (obviously) output some HTML to the screen. At the top and the bottom of this output, I want my company's header and footer pages that are included on all pages. I've tried to get these included in a couple of different ways:

1) open(HEADER,"header.htm");
while(<HEADER>) {
print $_
}

2) print <<END;
<!--#include virtual="header.htm"-->
END

I can't get any of the HTML in the file outputted. If you can see whats going wrong, ill be very glad of some assistance :)

Cheers. Smile


Paul
Enthusiast

Aug 7, 2002, 2:24 AM

Post #2 of 4 (511 views)
Re: [Zippy] Reading HTML from a file with Perl [In reply to] Can't Post

Well firstly you can throw example 2 out of the window Smile ....you cannot use SSI in cgi generated html.

Example one should work fine, just use some error checking...


Code
open FH, "header.htm" or die "Can't open header.html: $!"; 
print while (<FH>);
close FH;



Zippy
New User

Aug 7, 2002, 2:36 AM

Post #3 of 4 (508 views)
Re: [RedRum] Reading HTML from a file with Perl [In reply to] Can't Post

I've been looking at using a package called HTML::PullParser to extract the data from the file. Is this needed? Or am I completely barking up the wrong tree looking at that?


Paul
Enthusiast

Aug 7, 2002, 3:33 AM

Post #4 of 4 (501 views)
Re: [Zippy] Reading HTML from a file with Perl [In reply to] Can't Post

It depends what you want to do...just printing the whole file can be done as shown above.

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives