in reply to Crahes due to threads.

You are returning 1 or 2 on error from the subroutine, but the return value from $f->close() on success, which is probably true (also 1).

I suggest you return 0 (zero) on success, and test the return value from the $thn->join() for non-zero, so you can report an error. You should also change your error reporting (print statements) to use STDERR or warn instead of stdout.

Replies are listed 'Best First'.
Re^2: Crahes due to threads.
by jasoncollins (Novice) on Jul 23, 2010 at 16:33 UTC

    Good tip, I will change the print to STDERR