eval optional modules in blocks instead of strings.
authorMahlon E. Smith <mahlon@martini.nu>
Tue, 12 Jan 2016 00:16:33 -0800
changeset 87 475aff91675b
parent 86 9a5dacf95052
child 88 60f1cf97910d
child 91 80ec00959fbd
eval optional modules in blocks instead of strings.
shelldap
--- a/shelldap	Tue Jan 12 07:20:38 2016 +0000
+++ b/shelldap	Tue Jan 12 00:16:33 2016 -0800
@@ -539,7 +539,7 @@
 	# not installed and Net::LDAP decides it is required.
 	#
 	if ( $conf->{'tls'} || $conf->{'server'} =~ m|ldaps://| ) {
-		eval 'use IO::Socket::SSL';
+		eval { require IO::Socket::SSL; };
 		die qq{IO::Socket::SSL not installed, but is required for SSL or TLS connections.
 You may try connecting insecurely, or install the module and try again.\n} if $@;
 	}
@@ -581,7 +581,7 @@
 		}
 	}
 
-	undef $@; eval 'use Authen::SASL';
+	undef $@; eval { require Authen::SASL; };
 	my ( $sasl, $sasl_conn );
 	my $has_sasl = ! $@;
 	my $use_sasl = $has_sasl && $conf->{'sasl'};
@@ -2308,7 +2308,7 @@
 use Getopt::Long;
 use YAML::Syck;
 use Pod::Usage;
-eval 'use Term::ReadLine::Gnu';
+eval { require Term::ReadLine::Gnu; };
 warn qq{Term::ReadLine::Gnu not installed.
 Continuing, but shelldap is of limited usefulness without it.\n\n} if $@;