Data::Dumper->dump()ing a hash?
From: Dan Anderson (dan_at_mathjunkies.com)
Date: 10/30/03
- Next message: Rob Dixon: "Re: Range of dates help needed"
- Previous message: Dan Muey: "RE: Password Authentication"
- Next in thread: Kevin Pfeiffer: "Re: Data::Dumper->dump()ing a hash?"
- Reply: Kevin Pfeiffer: "Re: Data::Dumper->dump()ing a hash?"
- Reply: Kevin Old: "Re: Data::Dumper->dump()ing a hash?"
- Reply: Tore Aursand: "Re: Data::Dumper->dump()ing a hash?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
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
- Next message: Rob Dixon: "Re: Range of dates help needed"
- Previous message: Dan Muey: "RE: Password Authentication"
- Next in thread: Kevin Pfeiffer: "Re: Data::Dumper->dump()ing a hash?"
- Reply: Kevin Pfeiffer: "Re: Data::Dumper->dump()ing a hash?"
- Reply: Kevin Old: "Re: Data::Dumper->dump()ing a hash?"
- Reply: Tore Aursand: "Re: Data::Dumper->dump()ing a hash?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]