AnyEvent-Process
view release on metacpan or search on metacpan
lib/AnyEvent/Process.pm view on Meta::CPAN
}
} elsif ($args->[0] eq 'open') {
open my $fh, $args->[1], $args->[2];
unless (defined $fh) {
croak "Opening file failed: $!";
}
push @fh_table, [$handle, $fh];
} elsif ($args->[0] eq 'decorate') {
my $out = $args->[3];
unless (defined $out or ref $out eq 'GLOB') {
croak "Third argument of decorate must be a glob reference";
}
my ($my_fh, $child_fh) = portable_pipe;
unless (defined $my_fh && defined $child_fh) {
croak "Creating pipe failed: $!";
}
my $on_read;
my $decorator = $args->[2];
if (defined $decorator and ref $decorator eq '') {
lib/AnyEvent/Process.pm view on Meta::CPAN
=item TYPE
Following types are supported:
=over 4
=item pipe
Opens an unidirectional pipe or a bidirectional socket (depends on the DIRECTION)
between the current and the new process. ARGS can be a glob reference, then the
second end of the pipe or socket pair is connected to it, or C<handle =E<gt>
[handle_args...]>, where handle_args are an argument passed to the
L<AnyEvent::Handle|AnyEvent::Handle> constructor, which will be connected to the
second end of the pipe or socket. In the a case handle_args is in the form of
C<method =E<gt> [method_args...]> and method is AnyEvent::Handle method, then
this method is called with method_args, after the handle is instantiated.
Example:
\*STDOUT => ['pipe', '>', handle => [push_read => [line => \&reader]]]
=item open
Opens the specified HANDLE using open with DIRECTION and ARGS as its arguments.
Example:
0 => ['open', '<', '/dev/null']
=item decorate
Decorate every line written to the HANDLE by the child. The DIRECTION must be
C<E<gt>>. ARGS are in the form C<DECORATOR, OUTPUT>. OUTPUT is a glob reference
and specifies a file handle, into which decorated lines are written. Decorator is
a string or a code reference. If the decorator is a string, it is prepended to
every line written by the started process. If the DECORATOR is a code reference,
it is called for each line written to the HANDLE with that line as its argument
and its return value is written to the OUTPUT.
Example:
\*STDERR => ['decorate', '>', 'Child STDERR: ', \*STDERR]
=back
( run in 0.667 second using v1.01-cache-2.11-cpan-49f99fa48dc )