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 ... }