IO::Pipe(3perl)
π IO::Pipe β supply object methods for pipes π
okay bestie, so this is IO::Pipe, a lil module from the Perl Programmers Reference Guide that gives you π«object methodsπ« for making pipes. It's giving very much "I don't want to wrangle raw filehandles myself" energy, and honestly? Slay.
β¨ SYNOPSIS β¨
use IO::Pipe;
$pipe = IO::Pipe->new();
if($pid = fork()) { # Parent
$pipe->reader();
while(<$pipe>) {
...
}
}
elsif(defined $pid) { # Child
$pipe->writer();
print $pipe ...
}
or
$pipe = IO::Pipe->new();
$pipe->reader(qw(ls -l));
while(<$pipe>) {
...
}
fr fr this is the whole vibe in one code block β fork it, read from one end, write to the other, and let the module handle the β¨dramaβ¨.
πΈ DESCRIPTION πΈ
IO::Pipe provides an interface to creating pipes between processes.
that's it. that's the whole thing. no cap. pipes between processes, made cute. π¦
π CONSTRUCTOR π
new ( [READER, WRITER] )β makes you a brand-newIO::Pipe, which is literally a reference to a newly created symbol (peep theSymbolpackage if you're nosy π).IO::Pipe::newoptionally takes two arguments, and those two besties should be objects blessed intoIO::Handle, or some subclass of it. Those two objects are what get used for the system call topipe. And if you hand it no arguments at all? Then the methodhandlesgets called on the fresh newIO::Pipeobject instead. π
Those two handles live in the array part of the GLOB until either reader or writer gets called. like, they're just chillin there. waiting for their moment. main character energy β
π«Ά METHODS π«Ά
reader ([ARGS])β the object gets re-blessed into a sub-class ofIO::Handleand becomes a handle sitting at the reading end of the pipe. π And if you passARGS? Thenforkgets called andARGSget passed along to exec. iykyk.writer ([ARGS])β same deal, bestie: the object is re-blessed into a sub-class ofIO::Handleand becomes a handle at the writing end of the pipe. βοΈ And yep, ifARGSare given,forkis called andARGSare passed to exec. twin behavior.handles ()β this one gets called during construction, byIO::Pipe::new, on the freshly createdIO::Pipeobject. It hands back an array of two objects blessed intoIO::Pipe::End, or a subclass of it. two lil ends. a whole pipe. obsessed. π
π SEE ALSO π
IO::Handle
π AUTHOR π
Graham Barr. Currently maintained by the Perl Porters. Please report all bugs at <https://github.com/Perl/perl5/issues>.
(if something's broken, go tell them!! they want to know!! π)
π COPYRIGHT π
Copyright (c) 1996-8 Graham Barr <gbarr@pobox.com>. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
and that's the whole page, bestie!! π₯³ this was documented for perl v5.44.0, dated 2026-10-17 β so yeah, she's fresh, she's iconic, she's IO::Pipe(3perl). go make some pipes. you're gonna eat. π
β¨π¦
π¦ where this page comes from
- arch rolling: perl 5.44.0-1 Β· Artistic-1.0-Perl AND GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms