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

Re: both base and sub class in same file

by Sidhekin (Priest)
on Oct 11, 2007 at 13:29 UTC ( [id://644222]=note: print w/replies, xml ) Need Help??


in reply to both base and sub class in same file

This is happening because base ends up requireing Foo, which in turns ends up doing Foo.pm, since it hasn't been donerequired yet ...

Update 2: The safeguard is in require, of course. ikegami++. The workaround below is still useful for those "executable modules", but unnecessary for most purposes.

(Oh, and for completeness, use happens at compile time, and so is run even with the -c option.)

Update: A workaround: Add a $VERSION variable to Foo, as this prevents base from trying to load it again:

package Foo; our $VERSION = 0.001; sub test { } 1; package Bar; use base Foo; sub test2 { } 1;

print "Just another Perl ${\(trickster and hacker)},"
The Sidhekin proves Sidhe did it!

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others lurking in the Monastery: (5)
As of 2024-04-24 01:00 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found