It's may not be just a scoping problem. Apache::Registry will cache the script inside a subroutine, similar to
#!/usr/local/bin/perl -w
use DBI;
use strict;
use diagnostics;
sub emulate_sub {
my $dbh;
sub connect {
$dbh = DBI->connect('dbi:Oracle:rdb1', 'scott', 'tiger') ||
die DBI::errstr;
}
}
I suspect that there's there's a copy with a connection, but the diconnect is not available.
UPDATE: I was updating the thread while perrin was replying. It probably won't affect what he says, as his answer still applies to the updated version | [reply] [d/l] |
Apache::Registry wraps it in a sub, but since $dbh is visible to both the connect and disconnect subs, it doesn't really matter. The $dbh variable will stay in scope, but the disconnect call will still work unless there is an actual bug in his code. The scoping seems to have been intentional.
| [reply] |