Shawn may have a different take but I think the "local" is misplaced and goes out of scope when the call's made.
Here's a potential workaround: out of scope On Sun, Mar 26, 2017 at 2:02 PM, SSC_perl <p...@surfshopcart.com> wrote: >> On Mar 26, 2017, at 1:15 PM, Shawn H Corey <shawnhco...@gmail.com> wrote: >> >> it would mean replacing the subroutine after the module was loaded. > > Thanks, Shawn, but I can’t get that to work. Reading perldoc Core > gives me the impression that I’d need to call the new sub, not the module. > If that’s true, I don’t see how it would work in this scenario. Here’s what > I tried: > > BEGIN { > use CGI::Carp qw(carpout fatalsToBrowser ); # noTimestamp > { > no warnings; > use Time::Piece; > local *CGI::Carp::stamp = sub { > my $frame = 0; > my ($id, $pack, $file, $dev, $dirs); > if (defined($CGI::Carp::PROGNAME)) { > $id = $CGI::Carp::PROGNAME; > } else { > do { > $id = $file; > ($pack, $file) = caller($frame++); > } until !$file; > } > if (! $CGI::Carp::FULL_PATH) { > ($dev, $dirs, $id) = File::Spec->splitpath($id); > } > return "$id: " if $CGI::Carp::NO_TIMESTAMP; > my $time = scalar(localtime); > my $dt = Time::Piece->strptime($time, '%a %b %d %H:%M:%S %Y'); > my $datetime = $dt->strftime('%Y-%m-%d %H:%M'); > return "[$datetime] $id: "; > } > } > open (my $log, '>>', ‘/path/to/error.log'); > carpout($log); > close ($log); > } > -- > To unsubscribe, e-mail: beginners-unsubscr...@perl.org > For additional commands, e-mail: beginners-h...@perl.org > http://learn.perl.org/ > > -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/