NAME
Chj::xIO - some IO utilities
SYNOPSIS
capture_stdout capture_stdout_
capture_stderr capture_stderr_
)
;
is capture_stdout {
"Hi!"
},
"Hi!"
;
is
substr
(capture_stderr {
warn
"nah"
}, 0,3),
"nah"
;
# if you want to avoid the '&' prototype:
is capture_stdout_(
sub
{
"Hi!"
}),
"Hi!"
;
my
$res
= with_output_to_file(
".xIO-test-out"
,
sub
{
"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.