Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?

CGI::Application beginner help THIS IS RESOLVED

by misterMatt (Novice)
on Jul 30, 2009 at 21:57 UTC ( #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: . 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 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. 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?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://784755]
Approved by ww
and nobody stirs...

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (5)
As of 2018-06-20 04:44 GMT
Find Nodes?
    Voting Booth?
    Should cpanminus be part of the standard Perl release?

    Results (116 votes). Check out past polls.