I'm trying to create a sub that will display all the active dbh's for use with mysql; unfortunately I can't seem to read the dbh objects from the drh. I can get it to work if I store a reference to the dbh in a "global" array (or hash), then loop through it and print one, but I wanted to try looping through the objects of the driver handle instead. Can the dbh's be retrieved by knowing just the drh object? I'm assuming if drh->{Kids}, etc. can count the handles, they would be accessible as well. I'd like to use this same procedure for creating a sortof disconnect_all sub as well.
My current code is attached, does anyone have ideas for doing this without the global array? Thanks for any help. . . ==================== use strict; use DBI; my $dbh_a, $dbh_b; my @dbArray; $dbh_a = DatabaseConnect( User=>'some', Pass=>'thing', DB=>'NA_APR', Host =>'localhost' ); $dbh_b = DatabaseConnect( User=>'some', Pass=>'thing', DB=>'NA_APR', Host =>'localhost' ); ShowDBH; exit(); sub ShowDBH { my $temp foreach $temp ( @dbArray ) { print $temp . "\n"; } } sub DatabaseConnect { my( $dUserName, $dPassword, $dsn, $dHost, $dDBase, $dbh ); my %arg = @_; $dUserName = $arg{User}; $dPassword = $arg{Pass}; if( !defined( $arg{DSN} ) ) { $dHost = $arg{Host}; $dDBase = $arg{DB}; $dsn = "DBI:mysql:$dDBase:$dHost"; } else { $dsn = $arg{DSN}; } $dbh = DBI->connect( $dsn, $dUserName, $dPassword, { RaiseError => 1, PrintError => 1 } ); push @dbArray, \$dbh; return $dbh; } Shawn Eisenzimmer Discover Financial Services, Inc.