[Pdx-pm] Data::Dumper::Simple and source filters

Ovid publiustemp-pdxpm at yahoo.com
Wed May 18 10:58:30 PDT 2005


Hi all,

I'm getting a variety of questions offlist about the required
parentheses in DDS and I figured it would be easier if I explain this
all at once.  Because DDS is a source filter, I have to parse a tiny
subset of Perl.  Because this is difficult, I wanted to reduce my
problem space as much as possible.  The relevant line of code in the
source filter is this:

  $DUMPER_FUNCTION\s*\(([^)]+)\)

That's very simplistic, but when you see that I require parentheses and
limit the argument list to variables, it makes the problem suprisingly
manageable.  Do you think the parens shouldn't be required?  Then maybe
I should match to a semi-colon but still allow optional parentheses:

  $DUMPER_FUNCTION\s*\(?([^)]+)\)?;

But that allows unbalanced parentheses.  Hmm ... maybe I can do this:

  $DUMPER_FUNCTION\s*(\()?([^)]+)(?(1)\));

Great.  Now I've used an experimental feature that few understand and
is not guaranteed to be remain in the perl regex engine.  (See "perldoc
perlre" and look for "Conditional expression" to see what I did).

I decided it wasn't worth the trouble and the potential bugs, so I just
said "parens required."

Cheers,
Ovid

-- 
If this message is a response to a question on a mailing list, please send
follow up questions to the list.

Web Programming with Perl -- http://users.easystreet.com/ovid/cgi_course/


More information about the Pdx-pm-list mailing list