1Fmode(3)              User Contributed Perl Documentation             Fmode(3)
2
3
4

NAME

6       FileHandle::Fmode - determine whether a filehandle is opened for
7       reading, writing, or both.
8

SYNOPSIS

10        use FileHandle::Fmode qw(:all);
11        .
12        .
13        #$fh and FH are open filehandles
14        print is_R($fh), "\n";
15        print is_W(\*FH), "\n";
16

FUNCTIONS

18        $bool = is_FH($fh);
19        $bool = is_FH(\*FH);
20         This is just a (more intuitively named) alias for is_arg_ok().
21         Returns 1 if its argument is an open filehandle.
22         Returns 0 if its argument is something other than an open filehandle.
23
24        $bool = is_arg_ok($fh);
25        $bool = is_arg_ok(\*FH);
26         Returns 1 if its argument is an open filehandle.
27         Returns 0 if its argument is something other than an open filehandle.
28
29        Arguments to the following functions  must be open filehandles. If
30        any of those functions receive an argument that is not an open
31        filehandle then the function dies with an appropriate error message.
32        To ensure that your script won't suffer such a death, you could first
33        check by passing the argument to is_FH(). Or you could wrap the
34        function call in an eval{} block.
35
36        Note that it may be possible that a filehandle opened for writing may
37        become unwritable - if (eg) the disk becomes full. I don't know how
38        the below functions would be affected by such an event. I suspect
39        that they would be unaware of the change ... but I haven't actually
40        checked.
41
42        $bool = is_R($fh);
43        $bool = is_R(\*FH);
44         Returns true if the filehandle is readable.
45         Else returns false.
46
47        $bool = is_W($fh);
48        $bool = is_W(\*FH);
49         Returns true if the filehandle is writable.
50         Else returns false
51
52        $bool = is_RO($fh);
53        $bool = is_RO(\*FH);
54         Returns true if the filehandle is readable but not writable.
55         Else returns false
56
57        $bool = is_WO($fh);
58        $bool = is_WO(\*FH);
59         Returns true if the filehandle is writable but not readable.
60         Else returns false
61
62        $bool = is_RW($fh);
63        $bool = is_RW(\*FH);
64         Returns true if the filehandle is both readable and writable.
65         Else returns false
66
67        $bool = is_A($fh);
68        $bool = is_A(\*FH);
69
70         Returns true if the filehandle was opened for appending.
71         Else returns false.
72         Not currently implemented on Win32 with pre-5.6.1 versions of perl (and
73         dies with appropriate error message if called on such a platform).
74

CREDITS

76        Inspired (hmmm ... is that the right word ?) by an idea from BrowserUK
77        posted on PerlMonks in response to a question from dragonchild. Win32
78        code (including XS code) provided by BrowserUK. Zaxo presented the idea
79        of using fcntl() in an earlier PerlMonks thread.
80
81        Thanks to dragonchild and BrowserUK for steering this module in
82        the right direction.
83
84        Thanks to attn.steven.kuo for directing me to the perliol routines
85        that enable us to query filehandles attached to memory objects.
86
87        And thanks to Jost Krieger for helping to sort out the test failures that
88        were occurring on Solaris (and some other operating systems too).
89

TODO

91        I don't know that anyone still runs pre-5.6.1 perl on Win32. However, if
92        someone likes to tell me how is_A() could be made to work on pre-5.6.1
93        Win32 perl, I would be quite happy to implement it.
94

LICENSE

96        This program is free software; you may redistribute it and/or
97        modify it under the same terms as Perl itself.
98        Copyright 2006-2008, 2009, 2010, 2012 Sisyphus
99

AUTHOR

101        Sisyphus <sisyphus at cpan dot org>
102
103
104
105perl v5.28.1                      2014-08-09                          Fmode(3)
Impressum