<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div><div>On Oct 17, 2011, at 11:42 AM, Richard Reina wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite">I have a module called Fax.pm that submits faxes to a local fax server. It is called by another program called User_utilities.pl.  Everything has worked great for years until recently when I added the following lines to Fax.pm<br>

<br>require "/usr/local/src/rushclient/rush_opps/<a href="http://get_hist.pl/" target="_blank">get_hist.pl</a>";<br>my $hist = get_hist();<br></blockquote><div> ^^^^^^^^^^^^^^^^^^^^^^</div><div>Is this line 130?</div><div><br></div><br><blockquote type="cite">The problem is that sometimes I *SOMETIMES* I get:<br><br>Undefined subroutine &Fax::get_hist called at Fax.pm line 130.<br>
<br></blockquote><div><br></div><br><blockquote type="cite">After getting this error if I restart User_utilities.pl and try again it works. However, if User_utilities.pm is left running and I try to use Fax.pm again, I get the error again.<br><br>Does anyone know what might be causing this error and what I might do to fix it?</blockquote><div><br></div>In general, the problem is that 'require' happens at runtime, and can be conditional, so you have to be really careful. If any other code in your program calls get_hist() before Fax.pm hits that 'require' call, then get_hist will not be defined yet and you'll get this error.</div><div><br></div><div>The best solution is to convert get_hist.pl to a module and 'use' it instead of 'require'ing it. Then the subroutine will be defined at compile time and ready for code anywhere in your program to call it.</div><div>
<span class="Apple-style-span" style="border-collapse: separate; color: rgb(0, 0, 0); font-family: 'Bitstream Vera Sans Mono'; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; font-size: medium; "><div><div><br class="Apple-interchange-newline">--</div><div>Quinn Weaver</div><div>PostgreSQL Experts, Inc.</div><div><a href="http://pgexperts.com/">http://pgexperts.com/</a></div><div>1-888-743-9778 (my extension: 510)</div></div><div><br></div></span><br class="Apple-interchange-newline">
</div>
<br></body></html>