You may want to take a look at the Filter::Handle module. Instead of using a separate subroutine to write to your logfile or STDERR you could simply use 'print STDERR "my message";' and let Filter::Handle do what you meant. Take a look at my node about Filter::Handle for an example. Regards,
-RT
Note that, as always, tie is not friends with any
C-level stuff (eg modules, system calls) that don't go
through Perl's IO layer, and tie doesn't like local
very much. Both of those are gotchas I like to warn
people about since I have been bitten by them in the
past.