Given that the bug report suggests only the is_W() function is used from FileHandle::Fmode I don't see why you can't replace the entire dependency with this short sub:
sub is_W {
my $fh = shift;
return 0 unless defined $fh;
return 0 unless defined fileno $fh;
local $\ = ''; # just in case
no warnings; # temporarily disable warnings
#my ($atime,$mtime) = (stat($fh))[8,9];
my $is_w = print $fh '';
#eval{ utime $atime, $mtime, $fh }; # can fail if futimes not avai
+lable
return $is_w;
}
my $file = "C:/tmp.txt";
printf "Null fh %d\n", is_W();
open F, ">", $file or die "Can't create $file $!\n";
printf "Writable fh %d\n", is_W(*F);
close F;
open F, $file or die "Can't create $file $!\n";
printf "Readable fh %d\n", is_W(*F);
close F;
printf "STDIN %d\n", is_W(*STDIN);
printf "STDOUT %d\n", is_W(*STDOUT);
printf "STDERR %d\n", is_W(*STDERR);
__DATA__
Null fh 0
Writable fh 1
Readable fh 0
STDIN 0
STDOUT 1
STDERR 1
Update added "no warnings;" as per barts suggestion. Added comments containing mtime restoration code (if desired) also per bart.
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.