[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

[MacPerl-WebCGI] compilation error



Hi Thomas:

I have typed in a small program from the Learning Perl and trying
to understand it.  I have typed in the program correctly I guess 
but it shows compilation error.  Can anyone of you out there check
for the mistakes that I may have made.  I can not find any so far.
Here is the program.

#!/usr/bin/perl  -w

use 5.004;
use strict;
use CGI qw (:standard);
use Fcntl qw (:flock);

sub bail {
my $error = "@_";
print h1 ("Unexpected Error"), p ($error), end_html;
die $error;
}

my (
$CHATNAME,
$MAXSAVE,
$TITLE,
$cur,
@entries,
$entry,
);

$TITLE= "Aztec Guestbook";
$CHATNAME = "/usr/tmp/chatfile";
$MAXSAVE = 100;


open (CHANDLE, "+< $CHATNAME") || bail ("cannot open $CHATNAME: $!");

flock (CHANDLE, LOCK_EX) || bail ("cannot flock $CHATNAME: $!");

while (!eof (CHANDLE) && $entries < $MAXSAVE) {
$entry = CGI -> new (\*CHANDLE);
push @entries, $entry;
}

seek(CHANDLE,0,0) || bail ("cannot rewind $CHATNAME: $!");
foreach $entry (@entries) {
$entry->save(\*CHANDLE);
}
truncate (CHANDLE, tell (CHANDLE)) || bail ("cannot truncate $CHATNAME:
$!");
close (CHANDLE) || bail ("cannot close $CHATNAME: $!");

print hr start_form;
print p ("Name:", $cur->textfield(
-NAME =>"name"));
print p ("Message:", $cur->textfield (
-NAME=>"message",
-OVERRIDE=>1,
-SIZE => 100));

print p (submit ("send"), reset ("clear"));
print end_form, hr;

print h2 ("Prior Messages");
foreach $entry (@entries) {
printf ("%s [%s]: %s",
$entry->param ("date"),
$entry ->param ("name"),
$entry->param ("message"));
print br ();
}
print end_html;



==== Want to unsubscribe from this list?
==== Send mail with body "unsubscribe" to macperl-webcgi-request@macperl.org