This file is indexed.

/usr/share/perl5/Getopt/Euclid/PodExtract.pm is in libgetopt-euclid-perl 0.3.2-1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
package Getopt::Euclid::PodExtract;


=head1 NAME

Getopt::Euclid::PodExtract - Perl::Tidy formatter to extract POD from source code

=head1 SYNOPSIS

    use Perl::Tidy;
    my $source = 'somefile.pl';
    my $pod    = '';
    Perl::Tidy::perltidy(
          argv      => [],
          source    => $source,
          formatter => Getopt::Euclid::PodExtract->new(\$pod),
    );
    print $pod;

=head1 DESCRIPTION

This is a formatter to plug into Perl::Tidy. This formatter simply takes source
code and deletes everything except for POD, which it returns in its raw form in
the specified variable. Do not use the destination option of perltidy as it is
ignored when using a formatter.

Perl::Tidy seems to have a more robust POD parsing mechanisms than Pod::Parser
or Pod::Simple, which makes it useful to correctly parse POD code, even when
rogue POD hides inside Perl variables, as in this example:

  use strict;
  use warnings;

  =head1 NAME
  
  Tricky

  =cut

  print "Starting...\n--------\n";
  my $var =<<EOS;

  =head1 FAKE_POD_ENTRY_HERE

  This should not be extracted as POD since it is the content of a variable

  =cut

  EOS

  print $var;
  print "--------\nDone!\n";
  exit;

  __END__

  =head1 SYNOPSIS

  Tricky file to test proper POD parsing

=head1 AUTHOR

Florent Angly C<< <florent.angly@gmail.com> >>

=head1 LICENCE AND COPYRIGHT

Copyright (c) 2011, Florent Angly C<< <florent.angly@gmail.com> >>

This module is free software; you can redistribute it and/or
modify it under the same terms as Perl itself.

=cut



sub new {
    # Initialize formatter
    my ($class, $strref) = @_;
    my $self = {};
    bless $self, ref($class) || $class;
    die "Error: Need to initialize the Getopt::Euclid::PodExtract formatter ".
      "with a string reference to store the results but none was given\n" if not
      defined $strref;
    die "Error: Need to initialize the Getopt::Euclid::PodExtract formatter ".
      "with a string reference to store the results but a ".ref($strref).
      " reference was given\n" if (not ref $strref  eq 'SCALAR');
    $self->{_strref} = $strref;
    return $self;
}


sub write_line {
    my ($self, $tokens) = @_;
    # This is called by perltidy, for each source code line
    # Print POD_START, POD and POD_END tokens only
    ${$self->{_strref}} .= $tokens->{_line_text} if $tokens->{_line_type} =~ m/^POD/;
}


1;