Submitted by David Farnham on Tue, 10 Aug 1999
09:49:46 -0700
Hello everyone,
I have written an input filter which searches
through code for comments of the form:
//!ppp: <some perl code>
//!ppp: <some more perl code>
It then runs the perl code on whatever code follows
it (up to the next !ppp: block or the end of the
file). The code which occurs after the 'ppp'
statement is stored in a variable named 'block'.
***
For example, if I am using the namespace 'LFor' but
I want to remove all occurrences of 'LFor::' in a
file for some reason, then I can put:
//!ppp: $block =~ s/LFor:://g;
at the beginning of the file. More complicated
sequences of Perl commands can be used, and
consecutive 'ppp' lines can be used to form a
larger sequence.
***
The 'ppp' stands for 'Perl Pre-Processor'. The
purpose of this was to come up with a way to store
perceps pre-processing information for a file
within the file itself. So, if there was something
that Perceps choked on, I could write a simple Perl
script to reformat the offending code/comments and
keep the script in the file with the code/comments.
I'm not a Perl programmer, so the input filter is
probably pretty ugly (A co-worker told me that it
looked like I was trying to write Perl code like I
write C code, which pretty much sums it up).
I hope this helps someone!