Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

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 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!


Comment on Re: both base and sub class in same file
Select or Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (10)
As of 2014-12-21 11:32 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (104 votes), past polls