Pod::Index::Entry - Represents Pod search result


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

Index


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

package Pod::Index::Entry;

use 5.008;
$VERSION = '0.14';

use strict;
use warnings;
use Pod::Index::Extract;

sub new {
    my ($class, %args) = @_;
    my $self = bless {
        %args, 
    }, $class;
    return $self;
}

sub podname  { shift->{podname}  }
sub line     { shift->{line}     }
sub filename { shift->{filename} }
sub context  { shift->{context} }
sub keyword  { shift->{keyword} }

sub pod {
    my ($self) = @_;

    return $self->{pod} if defined $self->{pod};

    my $filename = $self->filename;

    open my $in, "<", $filename or die "couldn't open $filename $!\n";
    open my $out, ">", \(my $pod) or die "couldn't open output fh: $!\n";

    my $parser  = Pod::Index::Extract->new(
        ppi_entry => $self,
    );

    <$in> for (1 .. $self->{line} - 1); # skip lines
    $parser->parse_from_filehandle($in, $out);

    return $self->{pod} = $pod;
}

1;