[sf-perl] dynamic use command

Randy J. Ray rjray at blackperl.com
Thu Apr 3 18:24:24 PDT 2008

I've had this happen before, too. What you need to do is wrap the whole 
statement in a string:

eval {
     "use Net::SMTP::SSL";

if ($@) {
     print "$net_smtp_ssl is missing\n";

You don't actually need the second "use". The code is now loaded and available 
to you. By using the eval, you have kept the application from stopping in the 
event that the module isn't available.

Randy J. Ray                                                rjray at blackperl.com
Sunnyvale, CA                                              http://www.rjray.org

More information about the SanFrancisco-pm mailing list