Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
The problem appears to be in your new method:
sub new { my $self = shift; my $q = $self->query(); my $output; my $dbh = $self->param('dbh'); return $output; }
You are shifting the first argument into $self, and then calling methods on it as if it were an object. However, the point of new is to create an object. The first argument is the name of the class, which in this case is 'bluebox'.

A standard new method might look something like this:

sub new { my $class = shift; my %data = { 'member data' => 'initial value' }; return bless \%data, $class; }
This creates a hash with some initial values, blesses the hash as a member of $class, and returns the resulting object.

In your module, you're inheriting from CGI::Application; you probably want to let CGI::Application create the object.

sub new { my $class = shift; my $self = $class->SUPER::new(); # call CGI::Application's new meth +od # do your own initialization, as desired }
I haven't tested this approach with CGI::Application. It depends on CGI::Application being properly written to support inheritance. That means that CGI::Application's new method, when it calls bless, must use whatever class name was passed in, rather than hard-coding 'CGI::Application'.

Update: P.S. If you don't need to do any extra initialization in the new method, you can simply inherit CGI::Application's new method, rather than defining your own.


In reply to Re: CGI::Application Error by chipmunk
in thread CGI::Application Error by czarfred

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others about the Monastery: (5)
As of 2024-04-18 19:10 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found