in reply to duplicating STDERR to a logfile...

How about (at least on UNIX)
open(STDERR,"|tee somefile 1>&2"); print STDERR "this goes to STDERR and somefile\n";
(The "1>2" ensures that what gets printed still goes to your main process's STDERR instead of STDOUT).

--JAS