I have a script where I want to decide at runtime to use one or the
other of two modules that have similar interfaces. However one of the
modules defines a constant that the other lacks, a constant I need to
use in my call to that module's constructor.  Is there a better way to
handle this than what I've done below? I want to allow the script to run
even when Net::FTPSSL hasn't been installed if the user doesn't ask for
tls to be used.

...
  if ($FTPS) {
    require Net::FTPSSL;
  }
  else {
    require Net::FTP;
  }

...

  if ($FTPS) {
    unless ($ftp = Net::FTPSSL->new( $FTPHostName, Debug => 2, Passive => 1,
                                     Encryption => 
eval('&Net::FTPSSL::IMP_CRYPT') ) ) {
      die ...;
    }
  }
  else {
    unless ($ftp = Net::FTP->new($FTPHostName, Debug => 0)) {
      die ...;
    }
  }
...

This is how IMP_CRYPT is defined in Net::FTPSSL:

   # Command Channel Protection Levels
   use constant IMP_CRYPT => "I";
   use constant EXP_CRYPT => "E";       # Default
   use constant CLR_CRYPT => "C";

-- 
Mike Small
[email protected]

_______________________________________________
Boston-pm mailing list
[email protected]
http://mail.pm.org/mailman/listinfo/boston-pm

Reply via email to