in reply to pass reference, to a hash with a reference to an open db handle, to a sub - help

References, like pointers, can be hard. But, in perl, I find that I can mostly ignore that. I still remember learning pointers in C - took me 2 months to learn everything else in that book, but 2 months just to get my head around this one thing. Since then, everything was downhill.

Anyway, back to your problem. Is there a reason why you're returning a reference to the DBD driver you get from DBI->connect? You could just as easily do:

sub ref_to_db { my $db = DBI->connect(...); return $db; }
That's because $db already is a reference to a DBD object.

But, for a minute, let's say this is really a simplification of your code, and there really is a reason to return a reference to it. In that case, you need to realise that since $DB (in your main code) is a reference to a DBD reference, then $$DB is merely a reference, and \$$DB is exactly the same as $DB. The same applies to your initialisation of %Booga - you can just do my %Booga = (DB => $DB). Ok, so that simplifies your call to closenow, but doesn't simplify closenow yet.

For the closenow function, you are missing one layer of indirection. It's probably easier if we use an intermediate variable (I did this in C++ all the time where I'd create extra reference variables just to save on effort trying to get my mind around too many layers at once):

sub closenow { my $rDB = shift; my $DB = $$rDB; $DB->disconnect(); }
That's probably done in a single line like ${$_[0]}->disconnect(), but I find that's just a bit too much line noise for my liking.

Finally, we should be able to extrapolate all this into your closeplease function:

sub closeplease { my $Booga = shift; my $DB = ${$Booga->{DB}}; $DB->disconnect(); }
The real purpose of passing in references like this is to be able to change the caller, such as:
sub closeitnow { my $rDB = shift; $rDB = $rDB->{DB} if ref $DB eq 'HASH'; my $DB = $$rDB; $DB->disconnect(); $rDB = undef; # now the caller's reference is gone, too! }
But I try to discourage this. It's too much action-at-a-distance for me. Instead, get rid of the extra layer of indirection, and your brain won't explode :-)