Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery

Re: both base and sub class in same file

by Sidhekin (Priest)
on Oct 11, 2007 at 13:29 UTC ( #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, 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?

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

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (7)
As of 2021-01-17 19:10 GMT
Find Nodes?
    Voting Booth?