in reply to Sharing a database handle among objects

One solution would be to pass your database handle ($dbh) to the Location and Vhost objects when they are created. Those objects would store the database handle internally and use it as needed. Provided your DB doesn't have any problems with executing more than one query at a time on a DB handle (some do) or if you code to avoid that behavior everything should work fine.

The following is untested, but should be right in spirit....

my $foo=Vhost->new("foo",$dbh); ....blah blah package Vhost; ..... sub new{ my $class = shift; my $self = {}; bless $self,$class; # set any default values here %{$self} = (); #there are much cleaner ways of doing this $self->{name}=shift; $self->{dbh}=shift; return $self; } sub bar{ my $self=shift; $self->{dbh}->prepare ... }