Hi,

I have a mod_perl handler which opens and closes an LDAP
connection each time they script is being started:

    $ldap = Net::LDAP->new('xxx.xxx.nokia.com') or die "$@";
    $ldap->bind();
...
    $ldap->unbind();

I would like to change they script so that the opened LDAP-
connection is being cached. Would using a global variable to
hold the LDAP-object and just checking if it's defined suffice:

    my $LDAP;
...
    $LDAP ||= Net::LDAP->new('xxx.xxx.nokia.com')->bind() or die "$@";

I'm worried if that's the correct way and if the $LDAP object
will reliably turn into undef on the timeouts. Thank you 

Regards
Alex

Reply via email to