in reply to storing database handle object in a variable

I see this simplest way, or I am missing something important in your query:

#create database handle: my $dbh = DBI->connect(...) or die "..."; #use the handle directly: $dbh->do("delete from mytable;"); #or prepare query: my $sth = $dbh->prepare("select 1 from dummy;");
You can find proper snippets in man DBI.

Definitely, use strict; use warnings, specially if you are not secure about the code - my opinion.