Getting what you wish for (in Data::Dumper::Simple)

Ovid on 2005-05-19T22:33:40

On the Portland Perl Monger's mailing list, a few people asked why parentheses were required on the Dumper function. Tom Phoenix specifically asked why I couldn't just parse a comma separate list of variables and use that as the arguments? (DDS is a source filter). I replied, half in jest, that the following didn't seem worth the trouble:



my $COMMA = qr/(?:,|=>)/;
my $SIGIL = qr/$@%*&/;
my $ATOM  = qr/[[:word:]]+/;
my $SEP   = qr/::/;
my $VAR   = qr/$SIGIL$SEP?$ATOM(?:$SEP$ATOM)*/;

my $WITH_PARENS = qr/$DUMPER_FUNCTION\s*\(([^)]+)\)/; my $VAR_LIST = qr/$VAR\s*(?:$COMMA\s*$VAR)*/;

my $MATCH = qr/($WITH_PARENS|$VAR_LIST)/;


I also said "patches welcome." So he sent me one, complete with tests. When I have more time to play around with this, I'll integrate it, make sure it works and upload it. I think this should make people happy to be able to write this:



print Dumper $foo, @bar, %baz;