rdfield has asked for the wisdom of the Perl Monks concerning the following question:

I'm getting a warning out of Apache 1.3.22/mod_perl 1.26_01-dev on W2K when calling Date::Manip::Date_Init. I've added in a couple of lines to show the current values of the variables mentioned in the offending 'unless':
[Thu Jan 31 15:39:41 2002] crmconfig.pm: $^X = [Thu Jan 31 15:39:41 2002] crmconfig.pm: $OS = Windows [Thu Jan 31 15:39:41 2002] crmconfig.pm: Use of uninitialized value in + pattern match (m//) at C:/Perl/site/lib/Date/Manip.pm line 3300.
Normally it's set OK:
C:\>perl -e "print $^X" C:\Perl\bin\perl.exe
Is there any way to set the value of $^X in mod_perl?

rdfield

Replies are listed 'Best First'.
Re: $^X not set in mod_perl
by theorbtwo (Prior) on Jan 31, 2002 at 16:15 UTC

    $^X is defined to be "The name that the Perl binary itself was executed as". In the case of mod_perl, perl was never executed; it was simply called as a library. You can simply set $^X like any other variable before calling Date_Init. "perl -le '$^X=31; print $^X'" works as expected (on my system, at lest: 5.6.1 on a UNIX box).

    Better, though, would be to figure out a way to have Date::Manip::Date_Init uses $^X at all; it would seem to have no good reason. Indeed, it uses it to check if taint is on. A better way to do that would be to check if somthing you know will be tainted is tainted useing the recipie in perlsec. (My suggestion would be to use a backtick for somthing like `echo`, or the return from readdir(), or some file input. Or hardwire it (if you do, you should have it to assume that taint checking is _off_, so if you accedently run it with them off, it's not a gaping hope.)

    TACCTGTTTGAGTGTAACAATCATTCGCTCGGTGTATCCATCTTTG ACACAATGAATCTTTGACTCGAACAATCGTTCGGTCGCTCCGACGC
      Yep, setting $^X manually does the trick. As with all the best/simplest answers..."why didn't I think of that?" :)

      Many thanks,

      rdfield