Sophie

Sophie

distrib > Mageia > 4 > x86_64 > by-pkgid > 587ec7e56f543befce3fce7ab395dade > files > 13

perl-Capture-Tiny-0.220.0-2.1.mga4.noarch.rpm

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' );