in reply to DBI and Constant

If you really want to do this as a constant, you can use the usual interpolation trick for non-scalars:
my $dbh = DBI->connect("DBI:mysql:database=@{[DBNAME]}",'username','pa +ssword') or die();
But I agree that a global is just as obvious to both the reader and the compiler.