It works if you do it right.
A Perl script will _never_ (well, hardly ever) see an environment variable
created by "shelling out". The only exception I know of to this rule is
that you can make it happen under VMS if you hold your tongue right.
But the %ENV hash is global, and visible everywhere in the script.
Moreover, environment variables set in %ENV _will_ be visible when you
"shell out".
Instead of asking "Why doesn't this work?" you might want to post a
(preferably _small_) example of the code that doesn't work. Yes, I _do_
recommend doing work to duplicate the problem in as small a script as
possible. I have solved my own problems several times by trying to prepare
small examples. It focuses the mind wonderfully.
Here's a sample of a script that _does_ successfully pass environment
variables to subroutines, and the output therefrom.
use strict;
use warnings;
@ARGV % 2 and die "We want an even number of arguments.\n";
my %want = @ARGV;
while (my ($name, $value) = each %want) {$ENV{$name} = $value}
check (\%want);
sub check {
my $chkenv = shift;
foreach my $name (sort keys %$chkenv) {
print $chkenv->{$name} eq $ENV{$name} ?
"\$want{$name} eq \$ENV{$name} eq '$chkenv->{$name}'\n" :
("Inconsistency: \$want{$name} is '$chkenv->{$name}',",
" but \$ENV{$name} is '$ENV{$name}'\n";
}
}
__END__
C:\>perl trw.pl foo bar bat man
$want{bat} eq $ENV{bat} eq 'man'
$want{foo} eq $ENV{foo} eq 'bar'
C:\>
Tom Wyant
This communication is for use by the intended recipient and contains
information that may be privileged, confidential or copyrighted under
applicable law. If you are not the intended recipient, you are hereby
formally notified that any use, copying or distribution of this e-mail,
in whole or in part, is strictly prohibited. Please notify the sender
by return e-mail and delete this e-mail from your system. Unless
explicitly and conspicuously designated as "E-Contract Intended",
this e-mail does not constitute a contract offer, a contract amendment,
or an acceptance of a contract offer. This e-mail does not constitute
a consent to the use of sender's contact information for direct marketing
purposes or for transfers of data to third parties.
Francais Deutsch Italiano Espanol Portugues Japanese Chinese Korean
http://www.DuPont.com/corp/email_disclaimer.html
_______________________________________________
Perl-Win32-Admin mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs