Why are Perl source filters bad and when is it OK to use them?

Why source filters are bad:

  1. Nothing but perl can parse Perl. (Source filters are fragile.)
  2. When a source filter breaks pretty much anything can happen. (They can introduce subtle and very hard to find bugs.)
  3. Source filters can break tools that work with source code. (PPI, refactoring, static analysis, etc.)
  4. Source filters are mutually exclusive. (You can’t use more than one at a time — unless you’re psychotic).

When they’re okay:

  1. You’re experimenting.
  2. You’re writing throw-away code.
  3. Your name is Damian and you must be allowed to program in latin.
  4. You’re programming in Perl 6.

Leave a Comment