develooper Front page | perl.perl5.porters | Postings from February 2003

Patch for Data::Dumper 2.12 to Allow Custom Hash Key/Value Separator

Thread Next
From:
chocolateboy
Date:
February 22, 2003 18:06
Subject:
Patch for Data::Dumper 2.12 to Allow Custom Hash Key/Value Separator
Message ID:
3E576A58.8010901@chocolatey.com
Hi there,

Please find enclosed a patch for Data::Dumper 2.12 which allows the user 
to define the hash key/value separator.

I've found this useful for dumping Perl data structures to JavaScript, 
whose array and hash literal syntax is exactly the same as Perl's apart 
from its
use of ':' rather than '=>' (or ','). There are pure Perl modules to do 
this, but they are not as comprehensive as Data::Dumper, and, of course,
Data::Dumper's XS implementation is much faster. It may be useful for 
export to other languages as well.

I've made the appropriate changes to the documentation. I'm afraid that 
I couldn't make head nor tail of dumper.t, but I've added a separate 
test, pair.t.

I actually hacked this a year ago, but looking at the Data::Dumper 
changelog, it seems that things move at an impressively stately pace in 
DD Country, so
perhaps it's appropriate that I've only just got round to finishing it 
off now :-)

Anyway, I hope it is of some use to you.

Best wishes,
chocolateboy.

Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About