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