NAME

Chj::xIO - some IO utilities

SYNOPSIS

use Chj::xIO qw(
   capture_stdout capture_stdout_
   capture_stderr capture_stderr_
   );

is capture_stdout { print "Hi!" }, "Hi!";
is substr(capture_stderr { warn "nah" }, 0,3), "nah";

# if you want to avoid the '&' prototype:
is capture_stdout_(sub { print "Hi!" }), "Hi!";

use Chj::xIO qw(with_output_to_file);
my $res = with_output_to_file(".xIO-test-out", sub { print "Hi"; 123 });
is $res, 123;
is do { open my $in, "<", ".xIO-test-out"; local $/; <$in> }, "Hi";

DESCRIPTION

Oh, there's Capture::Tiny ! Even uses the same names. TODO: move to that. Although, Capture::Tiny might be using 'dup', which would not be thread safe.

NOTE

This is alpha software! Read the status section in the package README or on the website.