Kirk Noda wrote: > The thread seemed to die off. Still, is there a way to use $ENV{TZ} to > modify the behavior of localtime?
The reason this does not work under modperl version 2.0 is because under handler "perl-script", %ENV is untied from the C environment. The localtime() function is implemented in C, and as a result, it will never see the changes you made to $ENV{TZ} from mod_perl. The way I got around this was to use Env::C, and override CORE::localtime() with something like: package MyLocaltime; use Env::C; sub import { my $class = shift; $class->export('CORE::GLOBAL', 'localtime'); } sub localtime { my $time = shift; $time = time unless defined $time; my $orig_tz = Env::C::getenv('TZ'); Env::C::setenv('TZ', $ENV{TZ}, 1); my @ret = CORE::localtime($time); Env::C::setenv('TZ', $orig_tz, 1); return @ret; } The real problem is that this is only safe under a prefork MPM because it is not thread safe. There really ought to be an option (IMO) where you can make the untie of %ENV under perl-script to be optional. Maybe something like PerlOptions +NoUntieEnv or something so that if you are running under a prefork MPM, you do not need to resort to tactics like the above. Regards, Michael Schout