I'm generating web pages. The script opens a file and writes the web page to it. Page is a class which contains the file open method. This works fine.
my $outfile="../index.html";
my $page=new Page;
my $fh=$page->open($outfile);
if ($fh =~ /ERROR:/) {
die "\n$fh\n";
}
Now I want to use the Page class from a CGI script, which means the $outfile should be STDOUT and work just fine. However I can't get the $fh filehandle to point to SDTOUT.
What am I doing wrong? This doesn't work.
my $outfile="STDOUT";
my $page=new Page;
my $fh=$page->open($outfile);
print "fh=$fh\n";
if ($fh =~ /ERROR:/) {
die "\n$fh\n";
}
This is the open method in the Page class:
sub open {
use FileHandle;
my ($self,$outFile)=@_;
# Open output file and complain on failure
$fh = new FileHandle ">$outFile";
if (!defined $fh) {
return ("ERROR: Could not open $outFile");
}
return $fh;
}
my $outfile="../index.html";
my $page=new Page;
my $fh=$page->open($outfile);
if ($fh =~ /ERROR:/) {
die "\n$fh\n";
}
Now I want to use the Page class from a CGI script, which means the $outfile should be STDOUT and work just fine. However I can't get the $fh filehandle to point to SDTOUT.
What am I doing wrong? This doesn't work.
my $outfile="STDOUT";
my $page=new Page;
my $fh=$page->open($outfile);
print "fh=$fh\n";
if ($fh =~ /ERROR:/) {
die "\n$fh\n";
}
This is the open method in the Page class:
sub open {
use FileHandle;
my ($self,$outFile)=@_;
# Open output file and complain on failure
$fh = new FileHandle ">$outFile";
if (!defined $fh) {
return ("ERROR: Could not open $outFile");
}
return $fh;
}