sub connect { if (eval { require Net::LDAPS; } and ! $@) { $ldap = Net::LDAPS->new($_[0]); } else { $ldap = Net::LDAP->new($_[0]); } return $ldap; } sub auth { $ldap = connect($_[2]); $ldap->bind($_[0],$_[1]) and return $ldap; } ($dn,$pass,$host) = @ARGV; auth($dn,$pass,$host) or die "auth failed\n"; $ldap = connect($host); $ldap->bind($dn,password=>$pass) ...
In my case, the auth and connect routines are both in a library which I use for a lot of different scripts, so I needed them to be generically useful; I can't always guarantee that the connect routine won't be run multiple times in the same script.
If I only run connect once, everything works fine, but if I run it twice, then the second time it doesn't record a failure, because Net::LDAPS has already failed to compile but is registered in %INC anyway.
Is there some kind of way to collect this information, or am I going to have to store a $::HAVESSL variable or something, which I hate?
And thanks for the quick response.
In reply to Re: Testing sub-module existence
by loosifer
in thread Testing sub-module existence
by loosifer
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |