Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations sizbut on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how do i open an existing html page from a perl script?

Status
Not open for further replies.

lisa66

Technical User
May 30, 2006
11
GB
thanks
 
The page i want to open is on my server - along with all my other pages including the perl file. I am trying to modify an existing script and have got to:

$FH = "HTML";
$FilePath = "confirmation.htm";
print "content-type: text/html\n\n";

open (FH, $FilePath);
close FH;

but I am obviously doing something wrong ...
 
Code:
#!/usr/bin/perl -w

use strict;

my $file = "/path/to/file.html";

open( FILE, $file ) or die $!;
while ( <FILE> ) {
	print $_ . "\n";     # line by line
}
close(FILE);

M. Brooks
 
To output the file contents to your browser do
Code:
#!/usr/bin/perl -w

use strict;

my $file = "/path/to/file.html";

print "content-type: text/html\n\n";

open( FILE, $file ) or die $!;
while ( <FILE> ) {
    print $_ . "<br>";     # line by line
}
close(FILE);

M. Brooks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top