#!/usr/bin/env perl use ExtUtils::testlib; use Mytest; use Capture::Tiny 'capture'; my $fh; open $fh, '>', 'out.txt' or die "open, $!"; my ($out, $err) = capture { Mytest::hello($fh); }; print "out=\n$out\nend out\n"; close $fh;