The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

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

SYNOPSIS

 perl -c -MFilter::ExtractSource input.pl >output.pl

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

DESCRIPTION

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!
   EOT
 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!
 EOT
 print $hello;

which can now be correctly parsed.

DEPENDENCIES

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

BUGS / ISSUES

Possibly lots.

Filter::ExtractSource has been tested with the Switch.pm 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 output.pl 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 bug-filter-extractsource@rt.cpan.org, or through the web interface at http://rt.cpan.org. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.

SEE ALSO

Filter::ExtractSource homepage - http://perl.jonallen.info/projects/filter-extractsource

Filter::Simple - http://search.cpan.org/dist/Filter-Simple

perlfilter manpage - http://www.perldoc.com/perl5.8.0/pod/perlfilter.html

AUTHOR

Written by Jon Allen (JJ) <jj@jonallen.info> / http://perl.jonallen.info

COPYRIGHT and LICENCE

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.