misterMatt has asked for the wisdom of the Perl Monks concerning the following question:
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: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
For completeness, my instance script 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;
#!/usr/bin/perl -w use CGI::Carp qw(fatalsToBrowser); use dictionarylookup; my $app = dictionarylookup->new(); $app->run();
|
|---|