<br><br><div class="gmail_quote">On Fri, Nov 12, 2010 at 5:04 PM, Jonathan Hogue <span dir="ltr">&lt;<a href="mailto:jon@hogue.org">jon@hogue.org</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">

no, BEGIN runs at compile-time too.<br>
<br>
found my error... it wasn&#39;t related to the difference between the 2 at<br>
all... I had a trailing space in my path name when doing the latter.<br>
<div><div></div><div class="h5"><br>
On Fri, Nov 12, 2010 at 5:02 PM, Len Jaffe &lt;<a href="mailto:lenjaffe@jaffesystems.com">lenjaffe@jaffesystems.com</a>&gt; wrote:<br>
&gt; use executes at compile-time, BEGIN runs after compilation, so you&#39;re<br>
&gt; use-ing a module before you unshift its home to @INC.<br>
&gt;<br>
&gt; On Fri, Nov 12, 2010 at 4:45 PM, Jonathan Hogue &lt;<a href="mailto:jon@hogue.org">jon@hogue.org</a>&gt; wrote:<br>
&gt;&gt;<br>
&gt;&gt; What&#39;s the difference between<br>
&gt;&gt; use lib &quot;/somepath&quot;;<br>
&gt;&gt; and<br>
&gt;&gt; BEGIN{ unshift( @INC, &quot;/somepath&quot; ) };<br>
&gt;&gt;<br>
&gt;&gt; When I do<br>
&gt;&gt; use DQ::SomeModule after the &quot;use lib&quot; approach, it works, but not<br>
&gt;&gt; after the BEGIN block, even though when I dump @INC, it shows the<br>
&gt;&gt; /somepath for both scenarios<br>
&gt;<br>
&gt; use executes at compile-time, BEGIN runs after compilation, so you&#39;re<br>
&gt; use-ing a module before you unshift its home to @INC.<br>
&gt;<br>
&gt; By the time you dump, the @INC arrays look the same, but the got there by a<br>
&gt; temporally different execution path<br></div></div></blockquote></div><br clear="all"><br><div><br></div><div>BEGIN runs after use.</div><div><br></div><div><br></div><div><a href="http://main.pl">main.pl</a></div><div>

----------------</div><div><div><br></div><div>use Foo;</div><div>use 5.10.1;</div><div><br></div><div>BEGIN {</div><div>   say &quot;main BEGIN&quot;;</div><div>}</div></div><div>--------</div><div><br></div><div><br></div>

<div>Foo.pm</div><div>-----------------------</div><div><div>package Foo;</div><div><br></div><div>use 5.10.1;</div><div><br></div><div>say &quot;I am Foo&quot;;</div><div><br></div><div>1;</div></div><div>----------------------------</div>

<div><br></div><div><div>C:\perlstuff&gt; perl <a href="http://main.pl">main.pl</a></div><div>I am Foo</div><div>main BEGIN</div><div><br></div><div>C:\perlstuff&gt;</div></div><div><br></div><div><br></div><div>the use executes before the BEGIN.</div>

<div><br></div><div><br></div><div><br></div><div><br></div><div><br></div><div><br></div><div><br>-- <br><a href="mailto:lenjaffe@jaffesystems.com">lenjaffe@jaffesystems.com</a>   614-404-4214<br>Scoutmaster Troop 156 - <a href="http://www.bsatroop156.org">www.bsatroop156.org</a><br>

Proprietor: <a href="http://www.theycomewithcheese.com/">http://www.theycomewithcheese.com/</a> - An Homage to Fromage<br>
</div>