Is there a Pod::Simple based module/script to remove all POD from Perl code?
Not yet in the dist, but here's a simple one:
use strict; use warnings;
{ package Pod::Simple::CodeOnly; use base qw(Pod::Simple); sub new { my $new = shift->SUPER::new(@_); $new->code_handler( sub { print {$_[2]{'output_fh'}} $_[0], "\n"; return; }); return $new; } 1; }
It's used like any Pod::Simple subclass, namely:
my $parser = Pod::Simple::CodeOnly->new; my $it; $parser->output_string( \$it ); $parser->parse_file( $filespec ); undef $parser; print $it; # or do whatever with $it
or to send to a FH:
my $parser = Pod::Simple::CodeOnly->new; $parser->output_fh( *STDOUT ); # or to wherever $parser->parse_file( $filespec);
If the document is not a file, but something in memory, then you'd use $parser->parse_string_document($the_content).
I'm not sure how I will resolve the question of whether code_line will be the line of code before or after it gets its encoding translated. So if we read a UTF16 file (as signalled by a leading BOM), I guess the lines of code should be code /after/ we've turned that from bytes into characters. But if the code is in Shift-JIS, as signalled by some kind of encoding declaration? Hmmmm.
-- Sean M. Burke [EMAIL PROTECTED] http://search.cpan.org/~sburke/