Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

CGI::Application beginner help THIS IS RESOLVED

by misterMatt (Novice)
on Jul 30, 2009 at 21:57 UTC ( [id://784755]=perlquestion: print w/replies, xml ) Need Help??

misterMatt has asked for the wisdom of the Perl Monks concerning the following question:

this issue has been resolved. The problem? Multiple typos ! doh! Hello again monks. I'm trying to work out a tiny application using CGI::Application, but I'm running into a bit of a snag. I'm trying to work from the information inside of this tutorial: http://www.perl.com/pub/a/2001/06/05/cgi.html . currently, the error I'm getting is this:
Error executing run mode 'show_search_form': Can't locate object metho +d "query" via package "self" (perhaps you forgot to load "self"?) at +dictionarylookup.pm line 29. at Z:/cgi-bin/dictionarylookup.cgi line 7
I'm not really sure what to make of it - because the tutorial I'm following seems to be the exact same as what I'm doing. I'm not sure why it's failing. This is my first time throwing anything like this together. If you can help me figure out why this is happening I would be grateful. dictionarylookup.pm looks like this:
#!/usr/bin/perl -w #this app is extremely simple - it's pretty much a sort of 'hello worl +d' #MVC application using the CGI::Application framework. #-------- use CGI::Carp qw(fatalsToBrowser); package dictionarylookup; use CGI::Application; use base 'CGI::Application'; use strict; #run at startup;; sub setup { my $self = shift; $self->start_mode('show_search_form'); $self->mode_param('rm'); $self->run_modes([qw/show_search_form display_form_results/]); } #sub to show form; sub show_search_form{ my $self = shift; my $q = self->query(); my $out = ''; $out .= $q->_start_html(-title => 'Dictionary Word Lookup'); $out .= $q->start_form(); $out .= $q->textfield(-name=>'word', -size=>50, -maxlength=>50); $out .= $q->hidden(-name => 'rm', -value => 'display_form_results' +); $out .= $q->submit(); $out .= $q->end_form(); $out .= $q->end_html(); return $out; } #sub to process/display results; #for now: just output the dang word! sub display_form_results{ my $self = shift; my $q = self->query(); my $tainted_word = $self->param('word'); my $out = ''; $out .= $q->_start_html(-title => 'Dictionary Word Lookup'); $out .= $q->h1($tainted_word); $out .= $q->end_html(); return $out; } 1;
For completeness, my instance script looks like this:
#!/usr/bin/perl -w use CGI::Carp qw(fatalsToBrowser); use dictionarylookup; my $app = dictionarylookup->new(); $app->run();

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://784755]
Approved by ww
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others goofing around in the Monastery: (3)
As of 2024-04-20 01:15 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found