Brethren

I was running Pod::Find::pod_find() to list pod-containing files in C:/perl/bin (after I installed the pmtools ), and I expected to see several .bat files in the list. But there were none, although several of them contain pod (e.g. pod2html.bat).

I looked into Pod::Find, drilled down into _check_and_extract_name() and I found the code ...
sub _check_and_extract_name { my ($file, $verbose, $root_rx) = @_; # check extension or executable flag # this involves testing the .bat extension on Win32! unless(-f $file && -T _ && ($file =~ /\.(pod|pm|plx?)\z/i || -x _ +)) { return undef; } return undef unless contains_pod($file,$verbose); # ... proceed with adding the accepted file to the lost of pods .. +.
... that decides to accept or reject a file, based on the extension and on file tests. A .bat file being a -f, -T and -x, it should be accepted, from reading above unless clause.

But this is not what happens - .bat files are rejected.

After some experimenting I found two workarounds that fix the problem:
# change the order of terms in && expression unless(-f $file _ && ($file =~ /\.(pod|pm|plx?)\z/i || -x _ ) && - +T) { return undef; # replace the _ variable by $file unless(-f $file && -T _ && ($file =~ /\.(pod|pm|plx?)\z/i || -x $f +ile )) { return undef;
I experimented some more and found that the malfunction of -x _ occurs inside a logical expression, but not in a series of simple statements. The script below demonstrates these findings.

Can anyone confirm my findings or tell me if I am mistaken somehow?
If the bug is confirmed, should I ask the module author (marek@saftsack.fs.uni-bayreuth.de) to add the workaround, or report the bug to ActiveState, or to someone else?

Rudif

#!perl -w use strict; use Pod::Find; # # Test Pod::Find::pod_find on C:/perl/bin # my $dir = 'C:/perl/bin'; my %pods = Pod::Find::pod_find({ -verbose => 1}, $dir); my @pods = keys %pods; my $n = keys %pods; printf "Found $n files containing pods: @pods\n"; printf "NOTE 1: above finds .pl but not .bat files containing pods\n\n +"; # # Test using _ variable in filestests # my $bat = 'c:/perl/bin/pod2html.bat'; my $exe = 'c:/perl/bin/perl.exe'; filetest ($bat); filetest ($exe); printf "NOTE 2: above shows that -x _ basically works as advertized\n\ +n"; sub filetest { my $file = shift; print "$file: "; stat($file); print " Readable" if -r _; print " Writable" if -w _; print " Executable" if -x _; print " Text" if -T _; print " Binary" if -B _; print "\n"; } # # Demo the bug and workarounds # # simplified from Pod::Find, -x _ does not work printf "1 $bat ok for pod: %d\n", (-f $bat && -T _ && -x _); # 4 workarounds printf "2 $bat ok for pod: %d\n", (-f $bat && -x _ && -T _); printf "3 $bat ok for pod: %d\n", (-f $bat && -x $bat && -T _); printf "4 $bat ok for pod: %d\n", (-f $bat && -T _ && -x $bat); printf "5 $bat ok for pod: %d\n", (-f $bat && -T $bat && -x $bat); printf "NOTE 3: above shows that -x _ does not work as advertized in c +ase 1\n\n";

In reply to Problem with filetest -x _ on Win2k AS Perl build 626 by Rudif

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.