Hello, I am trying to build a web application that relies on object inheritance which should theoretically be fine. The intention is to build the app around C::A, but I am running into a problem with objects that require inheritance. Whenever @ISA is invoked the program chokes. Take out @ISA (and obviously references the superclass to which it refers) and the app runs to successful (although useless) conclusion. Note the code below...

package Foo; use base 'CGI::Application'; use Bar; @ISA = ("bar"); sub cgiapp_init { my $foo = new_foo(); print "foo = $foo\n"; } sub setup { my $self = shift; $self->start_mode('mode1'); $self->run_modes( 'mode1' => 'sub1', 'mode2' => 'sub2', 'mode3' => 'sub3' ); $self->tmpl_path('/applicant'); } sub new_foo { my $class=shift; $class=ref($class)|| $class; my $foo = { stuff => '', morestuff => '', super => Bar->new() }; bless ($foo, $class); } sub sub1 { print "Show some stuff\n"; } 1;

When run as is from the command line there is an error:
"Can't locate object \"new\" via package Foo..."
When @ISA is commented out the results are the value of the $foo object (as instructed in ciapp_init()) and a bit of HTML as expected.

I have looked through the Monk archives and googled myself silly. Can someone point me in the right direction please?

Thank you


In reply to CGI::Application and object inheritance by spork

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.