Data::Dumper would seem a classic choice for your purpose of enhancing what you have.
While I'm already posting I'll give my $.02 of style for short programs. I like to pre-declar a subroutine named "dprint"(debug print), and it varies from program to program that I write - but usually its something like this:
our $DEBUG = 1;
sub dprint;
<.. Insert record into database .. >
dprint "Added record $x to database";
<...>
sub dprint
{
my $lt = scalar(localtime());
print "$lt - $_[0]\n" if ($DEBUG);
}