Mike,<br><br>I spoke a bit too soon.&nbsp; Something strange is going on -- or maybe it's not so strange.&nbsp; If Fax.pm is called after require "./QuoteJoke.pl"; has already been called<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; my $string = &amp;main::get_quote_joke();<br><br>works like a charm and "&amp;get_quote_joke();" fails with udefined subroutine.<br><br>If on the other hand if Fax.pm is called from a program when <br><br>require "./QuoteJoke.pl"; has not been previously called then<br><br>&nbsp;my $string = &amp;main::get_quote_joke(); <br><br>fails with undefined subroutine &amp;main::get_quote_joke()<br><br>and &amp;get_quote_joke(); works.<br><br>Any idea why this maybe the case?<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
 &nbsp;&nbsp; <br><br><br><b><i>Mike Fragassi &lt;frag@ripco.com&gt;</i></b> wrote:<blockquote class="replbq" style="border-left: 2px solid rgb(16, 16, 255); margin-left: 5px; padding-left: 5px;"> <br>On Fri, 28 Dec 2007, Richard Reina wrote:<br><br>&gt; How can one properly declare another script's subroutine from within a <br>&gt; Module.<br>&gt;<br>&gt; I would like to be able to do this:<br>&gt;<br>&gt; require "./QuoteJoke.pl";<br>&gt; my $string = &amp;get_quote_joke();<br>&gt;<br>&gt; from a my home made perl module Fax.pm<br>&gt;<br>&gt; without getting:<br>&gt;<br>&gt; Undefined subroutine &amp;Fax::get_quote_joke called at Fax.pm line 61<br><br>Inside Fax.pm, assuming that this module has the line 'package Fax;', <br>then calling any method 'foo' will be interpreted as a call to <br>&amp;Fax::foo.<br><br>If a file (.pl or .pm) does not have a 'package' declaration, its <br>commands are in the package 'main' by default.  If that's the case with <br>QuoteJoke.pl,
 then inside of Fax.pm, calling '&amp;main::get_quote_joke()' <br>should work.  Otherwise, if there's a package, use that instead of <br>'main'.<br><br>&gt; I know I am probably breaking some cardinal rule of perl but I can't <br>&gt; figure it out.<br><br>You're not really breaking anything, or doing anything crazy; you just <br>need to prepend the package name where the method comes from, when <br>you're calling it from inside a different package.<br><br>-- Mike F.<br>_______________________________________________<br>Chicago-talk mailing list<br>Chicago-talk@pm.org<br>http://mail.pm.org/mailman/listinfo/chicago-talk<br></blockquote><br>