Filter::ExtractSource - captures Perl code after processing by source filters


 perl -c -MFilter::ExtractSource >

Where contains Perl code which uses source filters, will be the code post filtering as passed to the Perl parser.


The concept of source filtering allows developers to alter and extend the Perl language with relative ease. One disadvantage however, is that some language extensions can break tools which attempt to parse Perl code, such as editors which perform syntax highlighting.

For example, the code

 use Filter::Indent::HereDoc;
 my $hello = <<EOT;
   Hello, World!
 print $hello;

is perfectly valid, but trying to parse it manually (i.e. without using perl) will fail as the EOT here-document terminator will not be found.

After processing by Filter::ExtractSource, the code becomes

 use Filter::Indent::HereDoc;
 my $hello = <<EOT;
 Hello, World!
 print $hello;

which can now be correctly parsed.


Filter::ExtractSource requires the Filter::Simple module to be installed.


Possibly lots.

Filter::ExtractSource has been tested with the and Filter::Indent::HereDoc source filters with good results. However in particular it has not been tested (and is unlikely to work) with any source filters which perform encryption or obfuscation of Perl code.

Any BEGIN blocks, CHECK blocks or use statements will be executed at compile-time (i.e. the code will be executed even when the '-c' switch is used). Therefore any data sent to the STDOUT stream by these blocks will be output before the filtered source code, so in the example above the file may need to be edited. A future release of Filter::ExtractSource will support writing the modified source code to a file instead of STDOUT to fix this problem.

Please report any bugs or feature requests to, or through the web interface at I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.


Filter::ExtractSource homepage -

Filter::Simple -

perlfilter manpage -


Written by Jon Allen (JJ) <> /


Copyright 2004 Jon Allen (JJ), All Rights Reserved.

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.