# create a variable to store the output in my $output = ""; # open a "file" that will store output in the variable # (requires 5.8; before that use CPAN module IO::Scalar) open my $fh, ">", \$output or die "Unexpected open to scalar failure: $!"; # save the default output file handle my $select_save = select($fh); # call your function call_function(); # clean up select($select_save); close $fh; # use output print "Got output: $output\n";