<br><br><div class="gmail_quote">On Mon, Oct 19, 2009 at 3:07 PM, Janine Goldstein <span dir="ltr">&lt;<a href="mailto:janine@ucar.edu">janine@ucar.edu</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
Hi Boulder Perl Mongers,<br>
<br>
I have been trolling the web looking for help with a programming problem and I found your group. Hopefully this is a good place to ask my question.<br>
<br>
<br>
I have some code that uses a Perl module and I would like to catch the<br>
error &quot;Can&#39;t locate &lt;module&gt;.pm in @INC&quot; at runtime, give use user an<br>
error message telling them they need to run the code on a different<br>
machine, and exit gracefully.<br>
<br>
I have tried:<br>
<br>
no warnings FATAL<br>
eval {use &lt;module&gt;}; warn $@ if $@;<br>
</blockquote><div><br></div><div><br></div><div>The problem here is that you are using </div><div><br></div><div>     eval BLOCK</div><div><br></div><div>rather than</div><div><br></div><div>     eval STRING</div><div><br>
</div><div>such as in</div><div><br></div><div>     eval &quot;use &lt;module&gt;&quot;.</div><div><br></div><div>The &quot;eval BLOCK&quot; form compiles the BLOCK -- so this form does not catch syntax or other compile-time errors. The &quot;use&quot; statement is a compile-time statement -- so if the module is not there, it will die when compilation, instead of  when running the &quot;eval&quot; as you expected.</div>
<div><br></div><div><br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">BEGIN {$SIG{&quot;__WARN__&quot;} = sub {...};<br>
try {use &lt;module&gt;;} catch {...};<br>
<br>
all to no avail. Am I messing up the syntax or is there something more<br>
fundamental going on?<br>
<br>
Thanks for any and all help!!!!<br>
<br>
Janine<br>
<br>
_______________________________________________<br>
Boulder-pm mailing list<br>
<a href="mailto:Boulder-pm@pm.org" target="_blank">Boulder-pm@pm.org</a><br>
<a href="http://mail.pm.org/mailman/listinfo/boulder-pm" target="_blank">http://mail.pm.org/mailman/listinfo/boulder-pm</a><br>
</blockquote></div><br>