- /x) {
- $digest->add(@contents);
- $digests{$filename} = $digest->digest;
-
- # lib files aren't analyzed if they are duplicates of files copied
- # there from some other directory. But to determine this, we need
- # to know their NAMEs. We might as well find the NAME now while
- # the file is open. Similarly, cpan files aren't analyzed unless
- # we're analyzing all of them, or this particular file is linked
- # to by a file we are analyzing, and thus we will want to verify
- # that the target exists in it. We need to know at least the NAME
- # to see if it's worth analyzing, or so we can determine if a lib
- # file is a copy of a cpan one.
- if ($filename =~ m{ (?: ^ (?: cpan | lib ) / )
- | $only_for_interior_links_re
- }x) {
- if ($found eq 'found_some_pod_line') {
- for (; $i < @contents; $i++) {
- next if $contents[$i] !~ /^=head1/;
- $found = 'found_NAME'
- if $contents[$i] =~ /^=head1 +NAME/;
- last;
- }
- }
- if ($found eq 'found_NAME') {
- $i++; # The NAME starts on a later line
-
- # Skip empty lines
- while ($contents[$i] !~ /\S/) { $i++ }
-
- # The NAME is the first non-spaces on the line up to a
- # comma, dash or end of line. Otherwise, it's invalid and
- # this pod doesn't have a legal name that we're smart
- # enough to find currently. But the parser will later
- # find it if it thinks there is a legal name, and set the
- # name
- if ($contents[$i] =~ /^ \s* ( \S+?) \s* (?: [,-] | $ )/x) {
- my $name = $1;
- $checker->name($name);
- $id_to_checker{$name} = $checker
- if $filename =~ m{^cpan/};
- }
- }
- elsif ($filename =~ m{^cpan/}) {
- $id_to_checker{$digests{$filename}} = $checker;
+ }x) {
+ if ($contents =~ /^=head1 +NAME.*/mg) {
+ # The NAME is the first non-spaces on the line up to a
+ # comma, dash or end of line. Otherwise, it's invalid and
+ # this pod doesn't have a legal name that we're smart
+ # enough to find currently. But the parser will later
+ # find it if it thinks there is a legal name, and set the
+ # name
+ if ($contents =~ /\G # continue from the line after =head1
+ \s* # ignore any empty lines
+ ^ \s* ( \S+?) \s* (?: [,-] | $ )/mx) {
+ my $name = $1;
+ $checker->name($name);
+ $id_to_checker{$name} = $checker
+ if $filename =~ m{^cpan/};