Subject: | Attempt to dereference an undefined reference |
Lines 44-47 in Net/LDAP/Express.pm:
# try connection
my $ldap = $class->SUPER::new($host,%args) ;
eval { $ldap->isa('Net::LDAP') } ;
croak "Cannot connect to $host: $@" if $@ ;
If Net::LDAP->new() fails, $ldap is undefined. This results in a cryptic error message:
Cannot connect to dc01.example.com: Can't call method "isa" on an undefined value at /usr/local/lib/perl5/site_perl/5.16/Net/LDAP/Express.pm line 46, <DATA> line 751.
It would be better to check that $ldap is defined before trying $ldap->isa inside the eval.
It might also be a good idea to call SUPER::new within the eval, in case it throws an exception.