in reply to Logging module sometimes writes its file in the wrong directory

I don't even know where to start looking for this bug,
It's opening in the "wrong" place, so let's start with the open call:
open(LOG, ">>$dir/$log_file") or croak "Unable to append to error log: + $!";
So it uses $dir .. now to see where that's set, which is in BEGIN .. and has this snippet:
$0 =~ '(.*[\\\/])\w+\.\w+$'; $dir = $1;
Several important items here:

Replies are listed 'Best First'.
Re^2: Logging module sometimes writes its file in the wrong directory
by Anonymous Monk on May 03, 2006 at 16:55 UTC
    Do you think that I should just get rid of the
    BEGIN { if ($::dir) { $dir = $::dir; } else { $0 =~ '(.*[\\\/])\w+\.\w+$'; $dir = $1; } }

    And just use
    use File::Basename; my $dir = dirname($0);

    in the module?
      If you want to use the directory where your script is, then yes. You can also use:
      use FindBin qw($Bin); my $dir = $Bin;
      -imran
      Update: if you want to open the file in the current directory that you are in, don't use $dir, just do open with the filename. This is unless a chdir was done.