I'm having a lot of trouble with the following code: (bluebox.pm)

package bluebox; use base 'CGI::Application'; use CGI::Carp qw(fatalsToBrowser); use DBI; use strict; sub setup { my $self = shift; $self->mode_param('mode'); $self->start_mode('list'); $self->run_modes( 'list' => \&list, 'view' => \&view, 'edit' => \&edit, 'new' => \&new, 'del' => \&del ); $self->param('dbh' => DBI->connect('dbi:mysql:adb, 'user', 'pass', { +RaiseError => 1, AutoCommit => 0 })); } sub teardown { my $self = shift; $self->param('dbh')->disconnect(); } sub list { my $self = shift; my $q = $self->query(); my $output; my $dbh = $self->param('dbh'); $output .= $q->header(); $output .= $q->start_html(); $output .= "This is the list page.\n"; $output .= $q->end_html; return $output; } sub view { my $self = shift; my $q = $self->query(); my $output; my $dbh = $self->param('dbh'); return $output; } sub edit { my $self = shift; my $q = $self->query(); my $output; my $dbh = $self->param('dbh'); return $output; } sub new { my $self = shift; my $q = $self->query(); my $output; my $dbh = $self->param('dbh'); return $output; } sub del { my $self = shift; my $q = $self->query(); my $output; my $dbh = $self->param('dbh'); return $output; } 1;


And as for the instance script: (bluebox.cgi)

#!/usr/bin/perl -w use bluebox; use strict; my $book = bluebox->new(); $book->run();


AS you can see, I have not implemented the different modes' subs yet (or I just have test prints where it would be), but that shouldn't have anything to do with the problem.

When I run the instance script (on a apache server at localhost, with the module in @INC), I get the following errors:

Can't use string ("bluebox") as a HASH ref while "strict refs" in use +at /usr/lib/perl5/site_perl/5.6.0/CGI/Application.pm line 361.


Does anyone have any ideas? This this something im doing, or is it maybe a bug (seems unlikely).

Also, what the monks here think about CGI::Application? FYI, this is going to eventully turn out to be an online phone book app (this isnt even the framework for the full implementation, just mostly trying out CGI::Application). Am I using CGI::Application in the right way? Any suggestion on the code so far would be greatly appreciated.

In reply to 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":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.