Sophie

Sophie

distrib > Fedora > 16 > i386 > by-pkgid > f8f6b9b37af515bc5e03d30d133ebb72 > files > 8

perl-Capture-Tiny-0.19-1.fc16.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' );