You can add syntax rules to Perl's parser. And you can add handlers for when a new syntax rule is triggered. As a result the handler either returns a string or a syntax tree.
Don't know how Perl is doing it and to what extent (only saw some samples), but I've seen it implemented in Boo (http://boo.codehaus.org/) ... where you have access to the entire compiler's pipeline.
Don't know how Perl is doing it and to what extent (only saw some samples), but I've seen it implemented in Boo (http://boo.codehaus.org/) ... where you have access to the entire compiler's pipeline.