in reply to Howto direct an output filehandle into directory?

You need quotes around result_dir/$OUTFILE_fname

When I attempt to run your code, I get:

Illegal division by zero at neversaint.pl line 7
as the text directory name 'result_dir' is being divided by the scalar $OUTFILE_fname.

Using use strict gives a 'bareword' error.

--------------------------------------------------------------

"If there is such a phenomenon as absolute evil, it consists in treating another human being as a thing."

John Brunner, "The Shockwave Rider".