Re: How to set environment variable
- From: hwigoda@xxxxxxxxxxxxxx
- Date: Thu, 27 Sep 2007 10:05:44 -0500 (GMT-05:00)
can't you set the environmental variables for the parent shell
by running a script as a . or here file?
-----Original Message-----
From: Jeff Pang <rwwebs@xxxxxxxxx>
Sent: Sep 27, 2007 10:02 AM
To: vikram vikram vikram <vicky_brsh@xxxxxxxxxxxxxx>
Cc: beginners@xxxxxxxx
Subject: Re: How to set environment variable
27 Sep 2007 14:47:42 -0000, vikram vikram vikram <vicky_brsh@xxxxxxxxxxxxxx>:
Hi All,
I am new to perl. I am using "Active Perl-5.8.8"
I want to set environment variable in a perl script
Ex - #!/usr/bin/perl
$ENV{HAI} = "hai";
and want to display the contents of the environment variable in the command line after executing the script.
But it is not displaying the contents if i give
echo $HAI
Hi,
When you start to run a perl program,a separate process is
started,which is different from your current shell process.So you
can't set the environment variables from another process to the
current shell process.
you can do a test,
$ perl -MData::Dumper -e '$ENV{TEST}=1;print Dumper \%ENV'
this would print what you want.
but,
$ echo $TEST
will get nothing.
--
To unsubscribe, e-mail: beginners-unsubscribe@xxxxxxxx
For additional commands, e-mail: beginners-help@xxxxxxxx
http://learn.perl.org/
.
- Follow-Ups:
- Re: How to set environment variable
- From: Chas. Owens
- Re: How to set environment variable
- From: Jeff Pang
- Re: How to set environment variable
- Prev by Date: Re: How to set environment variable
- Next by Date: Re: How to set environment variable
- Previous by thread: RE: How to set environment variable
- Next by thread: Re: How to set environment variable
- Index(es):
Relevant Pages
|