View on
MetaCPAN is shutting down
For details read Perl NOC. After June 25th this page will redirect to
BrowserUk > Win32-Fmode > Win32::Fmode



Annotate this POD

View/Report Bugs
Module Version: 1.0.6   Source  


Win32::Fmode - determine whether a Win32 filehandle is opened for reading, writing , or both.


 use warnings;
 use Win32::Fmode;
 my $mode = fmode( \*FH ); # FH is an open filehandle


The purpose is to work around the MS C runtime libraries lack of a function to retrieve the file mode used when a file is opened.

Exports a single function: fmode

Pass it an open Perl filehandle and it will return a numeric value that represents the mode parameter used on the open.

     fmode( \*FILEHANDLE ) &   1 and print "is readonly";
     fmode( \*FILEHANDLE ) &   2 and print "is writeonly";
     fmode( \*FILEHANDLE ) & 128 and print "is read/write";

If the parameter passed is not an open filehandle, the call will raise an exception.


Note: Ram files c<open FH, '<', \$ram> are not true filehandles (they are tied globs), and therefore do not have the associated CRT FILE structure from which this module obtains the information, and no way has yet been found to retrieve that information from them.

The module IO::String suffers the same limitations.


 This program is free software; you may redistribute it and/or
 modify it under the same terms as Perl itself.


 Written by BrowserUK.
 Copyright BrowserUK.
 bug reports to
syntax highlighting: