# Unidirectional pipe() or pipe-like thing based on sockets. # Depends whether pipe(), socketpair() and/or socket() # are available on the system. use IO::Pipely qw(pipely); my ($a_read, $a_write) = pipely(); # Bidirectional pipe-like socket pair, using socketpair(), # socket(), or a couple pipe()s depending on what's # available. use IO::Pipely qw(pipely2); my ($a_read, $a_write, $b_read, $b_write) = pipely2();
From the docs on github:
Pipes are troublesome beasts because there are a few different, incompatible ways to create them. Not all platforms support all ways, and some platforms may have hidden difficulties like incomplete or buggy support.
IO::Pipely provides a couple functions to portably create one- and two-way pipes and pipe-like socket pairs. It acknowledges and works around known platform issues so you don't have to.
On the other hand, it doesn't work around unknown issues, so please report any problems early and often.
IO::Pipely currently understands pipe(), UNIX-domain socketpair() and regular IPv4 localhost sockets. This covers every platform tested so far, but it's hardly complete. Please help support other mechanisms, such as INET-domain socketpair() and IPv6 localhost sockets.
IO::Pipely will use different kinds of pipes or sockets depending on the operating system's capabilities and the number of directions requested. The autodetection may be overridden by specifying a particular pipe type.