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

[MacPerl] help



Hello:

I have typed in the following script from Learning Perl. I
discarded the flock
function since it is not implemented in MacPerl.  When I run
the script it
shows following error:

<HR><FORM METHOD="POST"
ENCTYPE="application/x-www-form-urlencoded">
</HR># Can't call method "textfield" without a package or
object reference, <> chunk 1.
File '.LC 1:Desktop Folder:scripts:guest.pl'; Line 31

I am unable to understand the problem. Can someone out there
please guide me.

Thanks

Amitava Basu

===========================================================

#!/usr/bin/perl  -w

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

### ==========
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 = "chatfile.txt";
$MAXSAVE = 100;

open (CHANDLE, "+< $CHATNAME") || bail ("cannot open
$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-request@macperl.org