IO::Pipe(3pm)
π IO::Pipe(3pm) π
okay so this is a page from the Perl Programmers Reference Guide, and bestie, it's literally all about pipes. stay with me, it's shorter than it looks and honestly kind of iconic π«Ά
β¨ NAME β¨
IO::Pipe β it supplies object methods for pipes. that's the whole vibe. π
π SYNOPSIS π
okay so here's the first way you might use it β fork yourself a kid and split the pipe between you:
use IO::Pipe;
$pipe = IO::Pipe->new();
if($pid = fork()) { # Parent
$pipe->reader();
while(<$pipe>) {
...
}
}
elsif(defined $pid) { # Child
$pipe->writer();
print $pipe ...
}
or, alternative route, just hand it a command and let it do the fork for you:
$pipe = IO::Pipe->new();
$pipe->reader(qw(ls -l));
while(<$pipe>) {
...
}
both are valid, both slay, pick whichever fits your situation πΈ
π¦ DESCRIPTION π¦
IO::Pipe gives you an interface for creating pipes between processes. that's it, that's the whole description, short and sweet, no notes π
π CONSTRUCTOR π
new ( [READER, WRITER] )
so this creates an IO::Pipe, which β plot twist β is a reference to a newly created symbol (check the Symbol package if you're curious, iykyk).
IO::Pipe::new optionally takes two arguments, and those lil guys should be objects blessed into IO::Handle, or a subclass of it. these two objects are what get used for the system call to pipe. β¨
if you give it no arguments at all? then method handles gets called on the new IO::Pipe object instead. no pressure.
these two handles just chill in the array part of the GLOB until you call either reader or writer. they're waiting. patiently. π
π METHODS π
reader ([ARGS])β the object gets re-blessed into a sub-class ofIO::Handleand becomes the handle at the reading end of the pipe. and if you passARGS? thenforkis called andARGSget passed to exec. go off πwriter ([ARGS])β same situation, except this one becomes the handle at the writing end of the pipe. it also gets re-blessed into a sub-class ofIO::Handle. and yep, ifARGSare given thenforkis called andARGSare passed to exec. twin behavior, different end π«Άhandles ()β this method gets called during construction byIO::Pipe::newon the newly createdIO::Pipeobject. it returns an array of two objects blessed intoIO::Pipe::End, or a subclass thereof. two lil ends, one for each side π
π₯ SEE ALSO π₯
IO::Handle β go read that one next, bestie π
π AUTHOR π
Graham Barr. currently maintained by the Perl Porters. please report all bugs at <https://github.com/Perl/perl5/issues> β they genuinely want to hear from you, no cap π
β 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. π
okay that's the whole page, you ate it up honestly. this was perl v5.42.3, dated 2026-11-03 β go forth and pipe responsibly π§π
π¦ where this page comes from
- alpine 3.24: perl-doc 5.42.3-r0 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms