Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Re: Filter::Interpolate

by BrentDax (Hermit)
on Jul 07, 2001 at 12:31 UTC ( [id://94704]=note: print w/replies, xml ) Need Help??


in reply to Filter::Interpolate

I managed to rewrite this in a far smaller form. Also, at Damian Conway's urging, I renamed the module to Perl6::Interpolators. The pod is basically the same, with the first paragraph of 'BUGS' removed. Anyway, here's the new code, which uses Text::Balanced:

package Perl6::Interpolators; use Filter::Simple; use Text::Balanced qw(extract_codeblock); FILTER { my($inside_stuff, $t, $pos); while(($pos=index($_, '$(')) != -1) { $t=substr($_, $pos); $inside_stuff=extract_codeblock($t, '()', qr/\$/); s<\$\Q$inside_stuff\E><\${\\scalar$inside_stuff}>; } ($inside_stuff, $t, $pos)=(undef, undef, undef); while(($pos=index($_, '@(')) != -1) { $t=substr($_, $pos); $inside_stuff=extract_codeblock($t, '()', qr/\@/); s<\@\Q$inside_stuff\E><\@{[$inside_stuff]}>; } };

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others imbibing at the Monastery: (5)
As of 2024-04-26 09:26 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found