Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re: CGI::Application and object inheritance

by sacked (Hermit)
on Jul 27, 2005 at 14:30 UTC ( [id://478615]=note: print w/replies, xml ) Need Help??


in reply to CGI::Application and object inheritance

When you assign to @ISA, you are removing the reference to CGI::Application. Putting a print "@ISA\n" after the use base... line and then after the @ISA=... line shows the problem:
package Foo; + use base 'CGI::Application'; print "@ISA\n"; use Bar; @ISA = ("Bar"); print "@ISA\n"; # at this point Foo only inherits from Bar __END__ CGI::Application Bar
Rather than mixing use of use base and directly assigning to @ISA, consider the use of @ISA alone:
use CGI::Application; use Bar; @Foo::ISA = qw(CGI::Application Bar);
BTW, I believe "bar" should be capitalized in your original code.

--sacked

Replies are listed 'Best First'.
Re^2: CGI::Application and object inheritance
by ikegami (Patriarch) on Jul 27, 2005 at 14:58 UTC

    The order of your statements is deceptive. use happens at compile time, so your code actually runs them in the following order:

    package Foo; use base 'CGI::Application'; use Bar; print "@ISA\n"; @ISA = ("Bar"); print "@ISA\n";

    The first print should be wrapped in a begin to have it exected at before the use Bar.

    Same results in this case, but it's something for which one should look out, especially when demonstrating a point.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://478615]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others taking refuge in the Monastery: (4)
As of 2024-04-25 15:30 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found