Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.Sign up
Data::Dumper Feature Request: TrailingCommas option #15070
There's a thing we do in Perl frequently for convenience and to reduce the amount of superfluous diff lines in any generated code we write to git, the o'l trailing comma.
Seeing that unlike JSON, where you need a relaxed implementation of JSON to support it, making it a non-standard feature, Perl itself natively supports the trailing comma, and Data::Dumper isn't targeting a restricted language schema that prohibits them.
There's two ways of doing this really:
Though I only typically see the first.
I've also seen the following in the wild which leverages that you're more likely to add new items at the end of a list than the start, so reduces diff noise without adding extra "," tokens.
But that looks weird and unbalanced to me.
Naturally, adding a trailing comma for diff reasons only is of use when its a multi-line array, so people using Indent = 0 wouldn't want it.
But my next ticket will suggest an option to pack small single-dimensional arrays into single lines even on Indent = 1, and those arrays wouldn't need the trailing comma, but the larger arrays in the same structure that did span multiple lines would need it.
Site configuration information for perl 5.22.0:
Configured by kent at Fri Jun 19 08:03:55 NZST 2015.
Summary of my perl5 (revision 5 version 22 subversion 0) configuration:
@INC for perl 5.22.0:
Environment for perl 5.22.0:
Thanks for your suggestion. I have implemented this feature in commit cd3393c. This upgrades Data::Dumper to 2.159 (though that version is not currently available on CPAN).
I am marking this ticket "pending release"; this version of Data::Dumper is expected to appear in Perl 5.23.6 (due on or around 2015-12-20), and then in Perl 5.24.0 (due in May 2016).