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

We are trying to migrate from 5.003 to 5.8.7 on a Windows server. The following code produces different results depending on Perl version:
use Env; $ENV{'MYVAR'} = '123'; $ENV{'myvar'} = '123'; Env::import; print "\$MYVAR: $MYVAR\n" , "\$myvar: $myvar\n";
On Perl 5.003 it produces:
$MYVAR: 123 $myvar: 123
On Perl 5.8.7 it produces:
$MYVAR: 123 $myvar:
Can andyone suggest what is happening? We have a large amount of code that depends on both variables being set. (I didn't write this stuff!)

Replies are listed 'Best First'.
Re: Env module problem
by ikegami (Patriarch) on Jun 07, 2006 at 18:15 UTC

    Windows environment variables are case-insensitive. Your 5.003 is buggy, and your 5.8.7 is corrent.

    >set myvar=123 >set MYVAR=456 >echo %myvar% 456 >echo %MYVAR% 456

    Update: The bug has been fixed at least since

    This is perl, v5.6.1 built for MSWin32-x86-multi-thread (with 1 registered patch, see perl -V for more detail) Copyright 1987-2001, Larry Wall Binary build 633 provided by ActiveState Corp. http://www.ActiveState. +com Built 21:33:05 Jun 17 2002

    I can't find any reference to it in the deltas, but it could be mentioned in the Changes file.

Re: Env module problem
by socketdave (Curate) on Jun 07, 2006 at 18:22 UTC
    I get:
    $MYVAR: 123 $myvar: 123
    on various versions from 5.6.0 to 5.8.8 on Linux, but I also see your unexpected output on Activestate 5.8.7 on Win2k.