in reply to checking whether DBI connection made
But if you have more than one potential data source (or if you like the visual effect ;) you can use it to wait and initialize the objects as needed.
#!/usr/bin/perl -w use strict; package Queries; my ($db_handle, $ldap_connection); sub data_query_one { $db_handle ||= new Sybase::DBlib(); ... } sub data_query_two { $db_handle ||= new Sybase::DBlib(); ... } sub ldap_query_one { $ldap_connection ||= new LDAP::Conn(); ... } # &c. sub clean_up { $ldap_connection->close if $ldap_connection; $db_handle->release if $db_handle; } 1;
|
|---|