in reply to printing sub return values to a file

You write to a file using
print $fh EXPR;

EXPR can be any expression, including a subroutine call.