Data::Dumper->dump()ing a hash?

From: Dan Anderson (dan_at_mathjunkies.com)
Date: 10/30/03


To: beginners@perl.org
Date: Thu, 30 Oct 2003 16:53:14 -0500

When I use the following code to dump a hash:

    $entry{"genre"} = $genre;
    $entry{"artist"} = $artist;
    $entry{"album"} = $album;
    $entry{"disc"} = $disc;
    $entry{"file"} = $file;
    $entry{"fullpath"} = $fullpath;

    my $dumper = Data::Dumper->new( [%entry], [ qw () ] );
    my $dumpedvalues = $dumper->Dump();
    print $dumpedvalues . "\n";

I get the following output:

$VAR1 = "album";
$VAR2 = "Prose Combat";
$VAR3 = "disc";
$VAR4 = 1;
$VAR5 = "artist";
$VAR6 = "MC Solaar";
$VAR7 = "file";
$VAR8 = "04_a_la_claire_fontaine.ogg";
$VAR9 = "genre";
$VAR10 = "French Rap";
$VAR11 = "fullpath";
$VAR12 = "/ogg/French Rap/MC Solaar/Prose
Combat/04_a_la_claire_fontaine.ogg";

I've figured out that I can use qw() to change the variable names, but
is there any way to either get an output like the code that created the
hash, or in the form:

$hash = {
           album => "Prose Combat",
           # etc...
        }

Thanks in advance,

Dan