1IPC::Run::IO(3) User Contributed Perl Documentation IPC::Run::IO(3)
2
3
4
6 IPC::Run::IO -- I/O channels for IPC::Run.
7
9 NOT IMPLEMENTED YET ON Win32! Win32 does not allow select() on normal
10 file descriptors; IPC::RUN::IO needs to use IPC::Run::Win32Helper to do
11 this.
12
13 use IPC::Run qw( io );
14
15 ## The sense of '>' and '<' is opposite of perl's open(),
16 ## but agrees with IPC::Run.
17 $io = io( "filename", '>', \$recv );
18 $io = io( "filename", 'r', \$recv );
19
20 ## Append to $recv:
21 $io = io( "filename", '>>', \$recv );
22 $io = io( "filename", 'ra', \$recv );
23
24 $io = io( "filename", '<', \$send );
25 $io = io( "filename", 'w', \$send );
26
27 $io = io( "filename", '<<', \$send );
28 $io = io( "filename", 'wa', \$send );
29
30 ## Handles / IO objects that the caller opens:
31 $io = io( \*HANDLE, '<', \$send );
32
33 $f = IO::Handle->new( ... ); # Any subclass of IO::Handle
34 $io = io( $f, '<', \$send );
35
36 require IPC::Run::IO;
37 $io = IPC::Run::IO->new( ... );
38
39 ## Then run(), harness(), or start():
40 run $io, ...;
41
42 ## You can, of course, use io() or IPC::Run::IO->new() as an
43 ## argument to run(), harness, or start():
44 run io( ... );
45
47 This class and module allows filehandles and filenames to be harnessed
48 for I/O when used IPC::Run, independent of anything else IPC::Run is
49 doing (except that errors & exceptions can affect all things that
50 IPC::Run is doing).
51
53 INCOMPATIBLE CHANGE: due to the awkwardness introduced in ripping
54 pseudohashes out of Perl, this class no longer uses the fields pragma.
55
57 new I think it takes >> or << along with some other data.
58
59 TODO: Needs more thorough documentation. Patches welcome.
60
61 filename
62 Gets/sets the filename. Returns the value after the name change,
63 if any.
64
65 init
66 Does initialization required before this can be run. This includes
67 open()ing the file, if necessary, and clearing the destination
68 scalar if necessary.
69
70 open
71 If a filename was passed in, opens it. Determines if the handle is
72 open via fileno(). Throws an exception on error.
73
74 open_pipe
75 If this is a redirection IO object, this opens the pipe in a
76 platform independent manner.
77
78 close
79 Closes the handle. Throws an exception on failure.
80
81 fileno
82 Returns the fileno of the handle. Throws an exception on failure.
83
84 mode
85 Returns the operator in terms of 'r', 'w', and 'a'. There is a
86 state 'ra', unlike Perl's open(), which indicates that data read
87 from the handle or file will be appended to the output if the
88 output is a scalar. This is only meaningful if the output is a
89 scalar, it has no effect if the output is a subroutine.
90
91 The redirection operators can be a little confusing, so here's a
92 reference table:
93
94 > r Read from handle in to process
95 < w Write from process out to handle
96 >> ra Read from handle in to process, appending it to existing
97 data if the destination is a scalar.
98 << wa Write from process out to handle, appending to existing
99 data if IPC::Run::IO opened a named file.
100
101 op Returns the operation: '<', '>', '<<', '>>'. See "mode" if you
102 want to spell these 'r', 'w', etc.
103
104 binmode
105 Sets/gets whether this pipe is in binmode or not. No effect off of
106 Win32 OSs, of course, and on Win32, no effect after the harness is
107 start()ed.
108
109 dir Returns the first character of $self->op. This is either "<" or
110 ">".
111
112 poll
113 TODO: Needs confirmation that this is correct. Was previously
114 undocumented.
115
116 I believe this is polling the IO for new input and then returns
117 undef if there will never be any more input, 0 if there is none
118 now, but there might be in the future, and TRUE if more input was
119 gotten.
120
122 Barrie Slaymaker <barries@slaysys.com>
123
125 Implement bidirectionality.
126
127
128
129perl v5.16.3 2012-01-16 IPC::Run::IO(3)