| Pod-Stripper documentation | Contained in the Pod-Stripper distribution. |
Pod::Stripper - strip all pod, and output what's left
$>perl Stripper.pm
or
#!/usr/bin/perl -w
use strict;
use Pod::Stripper;
my $Stripper = new Pod::Stripper();
$Stripper->parse_from_filehandle(\*STDIN) unless (@ARGV);
for my $ARGV (@ARGV) {
$Stripper->parse_from_file($ARGV);
}
This be Pod::Stripper, a subclass of Pod::Parser. It parses perl files,
stripping out the pod, and dumping the rest (presumably code) to wherever
you point it to (like you do with Pod::Parser).
You could probably subclass it, but I don't see why.
I basically re-wrote Pod::Stripper on two separate occasions, and I know
at least 2 other people who'd use it, and thought It'd make a nice addition.
perl -MPod::Stripper -e"Pod::Stripper->new()->parse_from_file(shift)"
Stripper.pm
None. This one be object oriented (at least I'm under the impression that it is).
Pod::Parser and Pod::Parser, esp. the input_* and output_* methods
This module will correctly strip out get rid of hidden pod,
and preserve hiddencode, but like all pod parsers except perl,
it will be fooled by pod in heredocs (or things like that).
see perlpod and read Stripper.pm for more information.
D.H. aka crazyinsomniac|at|yahoo.com.
Copyright (c) 2002 by D.H. aka crazyinsomniac|at|yahoo.com. All rights reserved.
This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
props to all the perlmonks at perlmonks.org, and especiall danger and the ones who showed interest in Pod::Stripper
http://perlmonks.org/index.pl?node=Pod::Stripper
HEY THIS POD TOO (REALLy, == is valid, although some parsers might disagree)
podchecker will not complain
had to make sure
__END__
"this would still be hidden pod";
=cutyes, it is
| Pod-Stripper documentation | Contained in the Pod-Stripper distribution. |
package Pod::Stripper; # this one is a little more stylish (see perlstyle) use strict; use Pod::Parser; local $^W = 1; # flip on teh warnings use vars qw/ @ISA $VERSION/; $VERSION = 0.22; @ISA = qw(Pod::Parser); # Pod'Parser is also legal sub begin_input { my ($Stripper) = @_; ## SUPER cause I override parseopts, so the user can't mess w/it $Stripper->SUPER::parseopts('-want_nonPODs' => 1, '-process_cut_cmd' => 9, ,); $Stripper->{__2hidden_code}=0; return undef; } sub cutting { my ($Stripper, $cutting) = @_; $Stripper->{_CUTTING} = $cutting if defined $cutting; return $$Stripper{_CUTTING}; } sub begin_pod { my ($Stripper) = @_; $Stripper->cutting(1); return undef; } sub end_pod { my ($Stripper) = @_; $Stripper->cutting(0); return; } sub preprocess_paragraph { my ($Stripper, $text) = @_; if( $Stripper->cutting() ) { my $out_fh = $Stripper->output_handle(); print $out_fh $text; return undef; } else { return $text; } } sub command { my ($Stripper, $command, $paragraph, $line_num, $pod_para) = @_; if($paragraph =~ m/^=cut/mg) { $Stripper->{__2hidden_code} = 1 ; ## it's hidden code (the unseen =cut command) } if ($command eq 'cut') { $Stripper->cutting(1); ## it's non-pod now } else { $Stripper->cutting(0); ## it's pod now } } sub verbatim { &textblock(@_); } ## cause hidden code can be either sub textblock { my ($Stripper, $paragraph, $line_num, $pod_para) = @_; ## guess what we got? that's right, hidden code if($Stripper->{__2hidden_code}) { $Stripper->{__2hidden_code} = 0; my $out_fh = $Stripper->output_handle(); print $out_fh $paragraph; } } sub parseopts {undef} 1; ################################################################################ ################################################################################
package main; unless(caller()) { my $Stripper = new Pod::Stripper(); seek DATA,0,0; $Stripper->parse_from_filehandle(\*DATA);
print ">>>>>>>>>>>>>>> I AM NOT HIDDEN POD. PERL WILL EXECUTE ME";
my $BUT_BEFORE_THE_MODULE_ENDS = <<'A_TEST'; =head2 I AM INSIDE A HEREDOC WHERE ARE YOU? =cut =head2 I AM HIDDEN POD INSIDE A HEREDOC warn "really, I am" =cut print "AND I AM HIDDEN CODE INSIDE A HEREDOC"; =head2 BOO but hey, if the pod inside a heredoc gets eaten by a pod parser (as it shoulD) I see no problem here =cut A_TEST } 1; ### end of modules __END__
print "AND THIS WOULD STILL BE HIDDEN CODE";