1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
package GTSlogger; our $VERSION = '1.00'; use strict; use warnings; use Time::HiRes qw(time); use DateTime; use DateTime::Format::Strptime; use File::Path qw/make_path/; use initpath; use lib $CGILIB; use GTSconfig; # static method # (1) - message to log # (2) - filename or mytrace.log as default sub mytrace($;$) { my $message = shift; my $fname = shift || 'mytrace.log'; open( MYTRACE, '>>', GTSconfig::EXCHANGE_DIR.$fname ); # <<- FEHLER HIER print MYTRACE $message, "\n"; close MYTRACE; }
Quote[Thu Nov 17 17:52:11 2016] GTSlogger.pm: Bareword "GTSconfig::EXCHANGE_DIR" not allowed while "strict subs" in use at GTSlogger.pm line 36.
1 2 3
open( my $mytrace, '>>', GTSconfig::EXCHANGE_DIR.$fname ) or die $!; # hier ein "or die $!", damit du Fehler mitbekommst. Und meinst du $GTSconfig::...? print $mytrace $message, "\n"; close $mytrace; # das Close kannst du dir auch sparen, wenn $mytrace sowieso out of scope geht