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.


In reply to Re: Test for writable filehandles on win32 by tachyon-II
in thread Test for writable filehandles on win32 by tsee

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.