The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

IPC::Open2::Simple - The simplest way to read and write to a fork

VERSION

Version 0.01

SYNOPSIS

use IPC::Open2::Simple 'open2s'

my $input = "IPC::Open2 is too hard!\n";

my $ret = open2s(\my $output, \$input, '/bin/cat');

warn "status: $ret\n";  # 0

print $output;  # "IPC::Open2 is too hard!"

DESCRIPTION

IPC::Open2::Simple allows you to pipe data to a child process and read its ouput (STDOUT), all in one line! Contrary to IPC::Open2, you do not need to use file handles to communicate with the child process, which makes things a lot easier.

WARNING This module only works for simple use cases like the one in the synopsis, where the program called receives only 1 input and will print the output to STDOUT immediately and exit. STDERR is ignored and there is no timeout, so you should only use this module with programs and data you trust, or else your program might get stuck.

While this module has much less features than IPC::Run, it does not suffer from all its bugs and memory leaks, which make IPC::Run unusable in servers. IPC::Open2::Simple is also much more lightweight and has no non-core dependencies.

FUNCTIONS

open2s

$ret = open2s(\$output, \$input, @command)

Calls @command with the content of $input as STDIN and copies STDOUT into $output. STDERR is ignored. Returns the exit status of @command. Note that $output and $input must be scalar references.

BUGS

Please report any bugs or feature requests to bug-ipc-open2-simple at rt.cpan.org, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=IPC-Open2-Simple. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.

COPYRIGHT AND LICENSE

Copyright 2014 Olivier Duclos

This library is free software; you may redistribute it and/or modify it under the same terms as Perl itself.

SEE ALSO

IPC::Open2, IPC::Run