sub AuthenticateUser { my ($username,$password,$service) = @_; # this is my question if (DBI is not loaded and connected) { eval { use DBI; }; if ($@) { die($@); } } # go on and do stuff with $dbh # select warp.username,warp.password,services.service # from warp,services where blah blah blah return($service); }