Pod::Strip - Remove POD from Perl code


Pod-Strip documentation Contained in the Pod-Strip distribution.

Index


Code Index:

NAME

Top

Pod::Strip - Remove POD from Perl code

SYNOPSIS

Top

    use Pod::Strip;

    my $p=Pod::Strip->new;              # create parser
    my $podless;                        # set output string
    $p->output_string(\$podless);       # see Pod::Simple
    $p->parse_string_document($code);   # or some other parsing method
                                        #    from Pod::Simple
    # $podless will now contain code without any POD




DESCRIPTION

Top

Pod::Strip is a subclass of Pod::Simple that strips all POD from Perl Code.

METHODS

Top

All methods besides those listed here are inherited from Pod::Simple

new

Generate a new parser object.

replace_with_comments

Call this method with a true argument to replace POD with comments (looking like "# stripped POD") instead of stripping it.

This has the effect that line numbers get reported correctly in error messages etc.

AUTHOR

Top

Thomas Klausner, <domm@cpan.org>

BUGS

Top

Please report any bugs or feature requests to bug-pod-strip@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.

COPYRIGHT & LICENSE

Top


Pod-Strip documentation Contained in the Pod-Strip distribution.

package Pod::Strip;

use warnings;
use strict;

use base ('Pod::Simple');

our $VERSION = "1.02";

sub new {
    my $new = shift->SUPER::new(@_);
    $new->{_code_line}=0;
    $new->code_handler(
        sub {
            # Add optional line directives
            if ($_[2]->{_replace_with_comments}) {
                if ($_[2]->{_code_line}+1<$_[1]) {
                    print {$_[2]{output_fh}} ("# stripped POD\n") x ($_[1] - $_[2]->{_code_line} -1 );
                }
                $_[2]->{_code_line}=$_[1];
            }
            print {$_[2]{output_fh}} $_[0],"\n";
            return;
       });
    return $new;
}


sub replace_with_comments {
    my $self = shift;
    $self->{_replace_with_comments} = defined $_[0] ? $_[0] : 1;
}


1;
__END__