diff --git a/Changes b/Changes index b494404..2cfb11f 100644 --- a/Changes +++ b/Changes @@ -3,6 +3,10 @@ Change log for Test::Pod 1.49 * Changed license in the README to "Same as Perl" to match the license listed in `META.yml`, and in the POD as of v1.42. + * Tightened up the heuristic for matching Perl batch files to require + that the file end in `.bat`, as described in the documentation. + Patch from Luca Ferrari. + * Simplified some of the matching code. Patch from Luca Ferrari. 1.48 - 2013-05-06T04:47:00Z * Fixed test failure with versions of Pod::Simple lower than 3.24. Thanks diff --git a/lib/Test/Pod.pm b/lib/Test/Pod.pm index d0c04fd..ffa6808 100644 --- a/lib/Test/Pod.pm +++ b/lib/Test/Pod.pm @@ -156,9 +156,9 @@ so you can't have already called C. If C<@entries> is empty or not passed, the function finds all POD files in files in the F directory if it exists, or the F directory if not. A -POD file is one that ends with a Perl extension (F<.pod>, F<.pl>, F<.pm>, F<.PL>, F<.t>), -any file where the first line looks like a Perl-shebang or any batch file (F<.bat>) -starting with a line containing C<--*-Perl-*-->. +POD file is one that ends with a Perl extension (F<.pod>, F<.pl>, F<.pm>, +F<.PL>, F<.t>), where the first line looks like a Perl shebang, or a batch +file (F<.bat>) starting with a line containing C<--*-Perl-*-->. If you're testing a module, just make a F: @@ -231,23 +231,19 @@ sub _starting_points { sub _is_perl { my $file = shift; - # accept as a Perl file everything that ends with a well known Perl suffix ... - return 1 if $file =~ / [.](?:PL|p(?:[lm]|od)|t)$ /x; + return 1 if $file =~ /[.](?:PL|p(?:[lm]|od)|t)$/; open my $fh, '<', $file or return; my $first = <$fh>; close $fh; - + return unless $first; # ... or that has a she-bang as first line ... - return 1 if defined $first - && $first =~ /^(?:#!.*perl)/; + return 1 if $first =~ /^#!.*perl/; # ... or that is a .bat ad has a Perl comment line first - return 1 if defined $first - && $first =~ /(?:--\*-Perl-\*--)/ - && $file =~ / [.](?:bat) /xi; + return 1 if $file =~ /[.]bat$/i && $first =~ /--[*]-Perl-[*]--/; return; } @@ -274,8 +270,9 @@ Thanks to Andy Lester, David Wheeler, Paul Miller +Peter Edwards, and -Peter Edwards +Luca Ferrari for contributions and to C for the original code. =head1 COPYRIGHT AND LICENSE