<?xml version="1.0" encoding="windows-1252"?>
<node id="644222" title="Re: both base and sub class in same file" created="2007-10-11 09:29:49" updated="2007-10-11 05:29:49">
<type id="11">
note</type>
<author id="106949">
Sidhekin</author>
<data>
<field name="doctext">
&lt;p&gt; This is happening because [mod://base] ends up [doc://require]ing Foo, which in turns ends up [doc://do]ing Foo.pm, since it hasn't been &lt;strike&gt;done&lt;/strike&gt;required yet ... &lt;/p&gt;

&lt;p&gt; &lt;b&gt;Update 2:&lt;/b&gt; The safeguard is in require, of course.  [ikegami]++.  The workaround below is still useful for those "executable modules", but unnecessary for most purposes. &lt;/p&gt;

&lt;p&gt; (Oh, and for completeness, [doc://use] happens at compile time, and so is run even with the -c option.) &lt;/p&gt;

&lt;p&gt; &lt;b&gt;Update:&lt;/b&gt; A workaround: Add a $VERSION variable to Foo, as this prevents [mod://base] from trying to load it again: &lt;/p&gt;

&lt;c&gt;
package Foo;

our $VERSION = 0.001;

sub test { }

1;

package Bar;
use base Foo;

sub test2 { }

1;
&lt;/c&gt;

&lt;div class="pmsig"&gt;&lt;div class="pmsig-106949"&gt;
&lt;p align=center&gt;
&lt;font size=-1&gt;&lt;code&gt;print "Just another Perl ${\(trickster and hacker)},"&lt;/code&gt;&lt;/font&gt;
&lt;br&gt;The Sidhekin &lt;b&gt;proves&lt;/b&gt; Sidhe did it!&lt;/p&gt;
&lt;/div&gt;&lt;/div&gt;</field>
<field name="root_node">
644217</field>
<field name="parent_node">
644217</field>
</data>
</node>
