| 1 | # | ||||||||||
| 2 | # Copyright (c) 2003-2021 Christian Jaeger, copying@christianjaeger.ch | ||||||||||
| 3 | # | ||||||||||
| 4 | # This is free software, offered under either the same terms as perl 5 | ||||||||||
| 5 | # or the terms of the Artistic License version 2 or the terms of the | ||||||||||
| 6 | # MIT License (Expat version). See the file COPYING.md that came | ||||||||||
| 7 | # bundled with this file. | ||||||||||
| 8 | # | ||||||||||
| 9 | |||||||||||
| 10 | =head1 NAME | ||||||||||
| 11 | |||||||||||
| 12 | Chj::xpipe | ||||||||||
| 13 | |||||||||||
| 14 | =head1 SYNOPSIS | ||||||||||
| 15 | |||||||||||
| 16 | use Chj::xpipe; | ||||||||||
| 17 | my ($read,$write) = xpipe; # or xpipe READ,WRITE ? hmmm. not yet. | ||||||||||
| 18 | $read->xclose; | ||||||||||
| 19 | $write->xprint("Hello"); | ||||||||||
| 20 | |||||||||||
| 21 | =head1 DESCRIPTION | ||||||||||
| 22 | |||||||||||
| 23 | Returns two Chj::IO::Pipe filehandles/objects. | ||||||||||
| 24 | |||||||||||
| 25 | =head1 NOTE | ||||||||||
| 26 | |||||||||||
| 27 | You should trap SIGPIPE or the program will exit before an exception | ||||||||||
| 28 | is thrown. | ||||||||||
| 29 | |||||||||||
| 30 | =head1 SEE ALSO | ||||||||||
| 31 | |||||||||||
| 32 | L<Chj::IO::Pipe>, L<Chj::IO::File> | ||||||||||
| 33 | |||||||||||
| 34 | =head1 NOTE | ||||||||||
| 35 | |||||||||||
| 36 | This is alpha software! Read the status section in the package README | ||||||||||
| 37 | or on the L<website|http://functional-perl.org/>. | ||||||||||
| 38 | |||||||||||
| 39 | =cut | ||||||||||
| 40 | |||||||||||
| 41 | package Chj::xpipe; | ||||||||||
| 42 | 3 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 43 | 3 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 44 | 3 | ▶ | use warnings FATAL => 'uninitialized'; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 45 | 3 | ▶ | use Exporter 'import'; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 46 | |||||||||||
| 47 | 3 | our @EXPORT = qw(xpipe); | |||||||||
| 48 | |||||||||||
| 49 | 3 | ▶ | use Chj::IO::Pipe; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 50 | 3 | ▶ | use Carp; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 51 | |||||||||||
| 52 | 0 | ▶ | sub xpipe { | ||||||||
|
Subroutine
xpipe: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||
| 53 | 0 | ▶ | if (@_) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 54 | 0 | confess "form with arguments not yet supported"; | |||||||||
| 55 | } else { | ||||||||||
| 56 | 0 | my $r = Chj::IO::Pipe->new; | |||||||||
| 57 | 0 | my $w = Chj::IO::Pipe->new; | |||||||||
| 58 | 0 | ▶ | pipe $r, $w or croak "xpipe: $!"; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 59 | 0 | ($r, $w) | |||||||||
| 60 | } | ||||||||||
| 61 | } | ||||||||||
| 62 | |||||||||||
| 63 | 3 | 1; | |||||||||