in reply to redirect output

You should use the STDERR handle, which is pre-opened in every script. Generally, you may use it directly, and there is no need to open it.
print STDERR "processing..\n"; print $result; print STDERR "done\n";