# print to STDOUT instead of to disk your_function( $string, \*INPUT, "&STDOUT" ); # print to already-opened filehandle open OUTPUT, '> /tmp/somefile' or die "/tmp/somefile: $!\n"; your_function( $string, \*INPUT, "&OUTPUT" );