in reply to Re: (tye)Re: file opening question
in thread CGI Server Error

So is everyone saying that this script should work in theory? Because nothing is getting sent to the browser in either case.

Replies are listed 'Best First'.
Re: Re: Re: (tye)Re: file opening question
by tachyon (Chancellor) on Jul 04, 2001 at 15:06 UTC

    Hi Anon. This code will/does work

    #!/usr/local/bin/perl use strict; use CGI::Carp qw(fatalsToBrowser); # this is the required header print "Content-type: text/html\n\n"; # this will go to the browser print "<h1>Show me 'Hello World!' the browser window!</h1>" my $file = "new_guestbook.html"; open(F,"+< $file") or die "Could not open $file: $!"; my @file = <F>; s/date/localtime/eg for @file; seek F,0,0 or die "Could not seek in $file: $!"; truncate F,0 or die "Could not truncate $file: $!"; print F @file; # this rewrites file close F; # this goes to browser, you see nothing if @file is empty print @file

    Run the code above. You will see at least the message in the browser window. If you do not see your file then specify an accurate full path to that file and make sure it is not empty (if you want to see something).

    cheers

    tachyon

    s&&rsenoyhcatreve&&&s&n\w+t&"$'$`$\"$\&"&ee&&y&srve&&d&&print