in reply to Re: Errors from a simple Package
in thread Errors from a simple Package

Just have your debug logger open up the file for appending, e.g.:
use POSIX qw(strftime); sub log_msg { open(my $fh, ">>", 'log_file.txt') or die "Err: $!"; printf $fh "[%s] %s\n", strftime("%Y-%m-%d %H:%M:%S", localtime), sh +ift; close $fh; } ... log_msg("Log this message");

Replies are listed 'Best First'.
Re^3: Errors from a simple Package
by tel2 (Pilgrim) on Mar 17, 2011 at 22:02 UTC

    Thanks runrig,

    Good suggestion - I'm trying that now.  I hadn't considered opening the file evertime I want to append it.  Probably not a big overhead since I'll probably only be doing it when I'm trying to debug something.

    But do you know if/how I can share a filehandle (e.g. "DEBUG") between a script and a package?

    Thanks.