[sf-perl] dynamic use command

Herb Rubin herbr at pfinders.com
Thu Apr 3 18:19:31 PDT 2008


All,

I am trying to do an eval on a use command and if it works, then
do a "use" command for real, but Perl keeps trying to compile it and getting
the error that the module is missing.

I tried putting the module in a scalar and it helped a bit, but I'm missing something:

my $net_smtp_ssl = "Net::SMTP::SSL";

eval {
  use $net_smtp_ssl
};

if ($@) {
  print "$net_smtp_ssl is missing\n";
  exit;
} else {
  use $net_smtp_ssl;
}

Any ideas?

Herb



-- 
Herb Rubin
Pathfinders Software
http://www.pfinders.com



More information about the SanFrancisco-pm mailing list