I have the following in a script that runs under mod_perl
Logger::log("\$1 = '$1'");
Logger::log("\$ 1 = '$1'");
Logger::log("\\$1 = '$1'");
Which outputs the following into my log file:
logger: = ''
logger: $ 1 = ''
logger: \ = ''
$1 is known to be null. Is this a bug in mod_perl2 or is it something else I'm missing?
Did you try:
Logger::log(q!$1 = '! . $1 . q!'!);
or, to avoid warnings:
Logger::log(q!$1 = '! . ( defined $1 ? $1 : '' ) . q!'!);
The idea here is that q!...! doesn't interpolate its contents, so you know for sure the first part of the string will be $1 = ". If it's still not appearing in the output, then you know Logger::log() or something it calls is interpolating its arguments, which probably shouldn't happen.
Oh, and if you're using a more modern Perl, the second example can use ( $1 // '' ) instead.