Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re^2: Using Parse::RecDescent to parse Perl-ish strings without resorting to string eval

by polypompholyx (Chaplain)
on Feb 29, 2008 at 20:08 UTC ( [id://671279]=note: print w/replies, xml ) Need Help??


in reply to Re: Using Parse::RecDescent to parse Perl-ish strings without resorting to string eval
in thread Using Parse::RecDescent to parse Perl-ish strings without resorting to string eval

Yes, in the original code, there's some fiddling with <skip> (since whitespace has syntactic significance in the grammar), and unescaping of Unicode hex character escapes. I left them out for clarity.

I can probably live with handrolled code that parses its own definition of a double quoted string, since most of the interpolation is unnecessary, but I'm not sure of any way out with regexes: I'd like to be able to do something like:

$text = qr/$text/$modifiers

but $modifiers doesn't interpolate, and I can't think of any easy way to simulate this without having a very large switch statement.

  • Comment on Re^2: Using Parse::RecDescent to parse Perl-ish strings without resorting to string eval
  • Select or Download Code

Replies are listed 'Best First'.
Re^3: Using Parse::RecDescent to parse Perl-ish strings without resorting to string eval
by ikegami (Patriarch) on Feb 29, 2008 at 20:20 UTC
    my $mods_p = ''; my $mods_m = ''; ($opts{$_} ? $mods_p : $mods_m) .= $_ for qw( x i s m ); $re = qr/(?$mods_p-$mods_m:$re)/;
      Ah, of course. I am an idiot. ikegami++

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://671279]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others contemplating the Monastery: (6)
As of 2024-04-19 06:40 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found