Hi,
I'm writing a script that opens a file in the same folder to read. When I
run the script with PWS it doesn't open the JOURNAL file (see script) when I
run it from the command line it does - it read both files fine.
Why does it stop at the open statement in the browser? I just get the output
up to the file read command then it finishes (without a die statement
even!!)
If anyone could help it would be much appreciated.
Thanks,
Matt
SCRIPT BELOW
-----------------------------------------------------
#!perl -w
use Strict;
use CGI;
my $q = new CGI;
print $q->header;
if ($q->param('action') eq 'submit') {
&add2log($q);
}
sub add2log {
my ($q) = @_;
my $addblog;
$journal ="journal.html";
$template = "template.html";
#$backup="journal.html.bak"; # create a copy of the
original html to edit
#copy($journal,$backup);
#get the date here - for the mean time have it hard coded
my $date = '28/02/2001';
my $name = $q->param('name');
my $text = $q->param('text');
print "\$name = $name<br>\n";
print "\$text = $text<br>\n";
print "\$journal = $journal<br>\n";
#open the journal for reading
open JOURNAL, $journal or die "cannot open $journal for read: $!\n";
print "opened file $journal<br>\n";
while (<JOURNAL>) {
if (/<blog top>/i) {
print "found blog top tag<br>\n";
$addblog.=$_;
open TEMPLATE, $template or die "cannot open
$template for read: $!\n";
print "opened file $template<br>\n";
while (<TEMPLATE>) {
s/\$date/$date/; #add the
date
s/\$text/$text/; #add the
text
s/\$name/$name/; #add the
text
print;
$addblog.=$_;
}
close TEMPLATE;
} else {
$addblog.=$_;
}
}
close JOURNAL;
print "here it is:\n<br>$addblog\n";
}
_______________________________________________
Perl-Win32-Web mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/perl-win32-web