 <p>Meanwhile, you can also "capture a subroutine's print output to a variable."</p> <p>Just pass a scalar ref to <code>open</code>:</p> <pre><code>#! /usr/bin/env perl use common::sense; use autodie; sub tostring (&amp;) { my $s; open local *STDOUT, '&gt;', \$s; shift-&gt;(); $s } sub fake { say 'lalala'; say 'more stuff'; say 1 + 1, ' = 2'; say for @_; } for (tostring { fake(1, 2, 3) }) { s/\n/\\n/g; say "Captured as string: &gt;&gt;&gt;$_&lt;&lt;&lt;"; } </code></pre> <p>Output:</p> <pre><code>Captured as string: &gt;&gt;&gt;lalala\nmore stuff\n2 = 2\n1\n2\n3\n&lt;&lt;&lt; </code></pre>