$dbh=new db connection #some code here that calls subroutines sub test{ $sth=$dbh->prepare(etc..) } sub test2{ $sth=$dbh->prepare(etc..) }