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, independant 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 Implement bidirectionality.
58
60 Barrie Slaymaker <barries@slaysys.com>
61
62 filename
63 Gets/sets the filename. Returns the value after the name change,
64 if any.
65
66 init
67 Does initialization required before this can be run. This includes
68 open()ing the file, if necessary, and clearing the destination
69 scalar if necessary.
70
71 open
72 If a filename was passed in, opens it. Determines if the handle is
73 open via fileno(). Throws an exception on error.
74
75 open_pipe
76 If this is a redirection IO object, this opens the pipe in a
77 platform independant manner.
78
79 close
80 Closes the handle. Throws an exception on failure.
81
82 fileno
83 Returns the fileno of the handle. Throws an exception on failure.
84
85 mode
86 Returns the operator in terms of 'r', 'w', and 'a'. There is a
87 state 'ra', unlike Perl's open(), which indicates that data read
88 from the handle or file will be appended to the output if the
89 output is a scalar. This is only meaningful if the output is a
90 scalar, it has no effect if the output is a subroutine.
91
92 The redirection operators can be a little confusing, so here's a
93 reference table:
94
95 > r Read from handle in to process
96 < w Write from process out to handle
97 >> ra Read from handle in to process, appending it to existing
98 data if the destination is a scalar.
99 << wa Write from process out to handle, appending to existing
100 data if IPC::Run::IO opened a named file.
101
102 op Returns the operation: '<', '>', '<<', '>>'. See "mode" if you
103 want to spell these 'r', 'w', etc.
104
105 binmode
106 Sets/gets whether this pipe is in binmode or not. No effect off of
107 Win32 OSs, of course, and on Win32, no effect after the harness is
108 start()ed.
109
110 dir Returns the first character of $self->op. This is either "<" or
111 ">".
112
113
114
115perl v5.10.1 2009-07-13 IPC::Run::IO(3)