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

Re: [MacPerl] help



Hi David:

I finally got the script to work.  I am quite excited.  Thanks to all
of you.

Amitava

David J. Iberri wrote:

> The problem is that you're using a method call from $cur without having
> instantiated it.  This error (usually) only occurs when you're attempting to
> use object oriented packages (such as CGI.pm), and is pretty easy to fix.
> Just go to the CGI.pm documentation, and find the class that supports the
> textfield() method.  Once you've found it, use something like this before
> you call $cur->textfield() [where ClassJustFound is the name of the class
> that supports the textfield() method]:
>
> my $cur = new ClassJustFound;
>
> This will create an object for you ($cur, which you've been using), and Perl
> won't yell at you anymore when you call the textfield() method.
>
> > From: Amitava Basu <incas@vsnl.net>
> > Organization: Incas
> > Reply-To: incas@vsnl.net
> > Date: Sat, 18 Nov 2000 15:17:13 +0530
> > To: MacPerl Mailing List <macperl@macperl.org>
> > Subject: [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
> >
>
> # ===== Want to unsubscribe from this list?
> # ===== Send mail with body "unsubscribe" to macperl-request@macperl.org



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