|
Server : Apache System : Linux vps-1289444.devslamantis.cl 3.10.0-1160.139.1.el7.tuxcare.els2.x86_64 #1 SMP Mon Nov 3 13:30:41 UTC 2025 x86_64 User : vspt ( 1013) PHP Version : 7.4.33 Disable Function : NONE Directory : /usr/share/doc/perl-Capture-Tiny-0.24/examples/ |
use strict;
use warnings;
use Capture::Tiny qw/capture tee/;
print "Type some text. Type 'exit' to quit\n";
my ($out, $err) = tee {
while (<>) {
last if /^exit$/;
print "Echoing to STDOUT: $_";
print STDERR "Echoing to STDERR: $_";
}
};
print "\nCaptured STDOUT was:\n" . ( defined $out ? $out : 'undef' );
print "\nCaptured STDERR was:\n" . ( defined $err ? $err : 'undef' );