Re: How to set environment variable



On 27 Sep 2007 14:47:42 -0000, vikram vikram vikram
<vicky_brsh@xxxxxxxxxxxxxx> wrote:

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

Please help me out

Thanks in advance
Vikram

You need to set it from the current shell, once your perl program
exits so does you env setting you made. The ENV setting you made is
only alive throughout the life of the perl script.

Set the varible from you ~/.profile and read it in through perl.

I hope this helps


--
Rodrick R. Brown
http://www.rodrickbrown.com
.



Relevant Pages

  • RE: Segmentation Fault(Core dumped)
    ... But when I started testing my perl script, ... Compilation failed in require at ./test.pl line 13. ... > official business of Sender. ...
    (perl.dbi.users)
  • Cgi with GD grap, and displaying graphs
    ... I am trying to create a web page, which takes data from a file and builds a graph with GD, these are then saved as pictures, I then use the cgi script to call the pics using dynamically generated HTML page, using a system call to another perl script. ... When I do this, I get a 500 internal error and I've traced this down to a permissions problem, as the apache user doesn't have the permissions to write the pic's in the /var/www/html file. ... I get GD to display the graph with in the perl script and not right pic's but dynamically display them, rather than calling another script to display the HTML, using system "html_diplay.pl", essentially two scripts instead of one. ...
    (perl.beginners)
  • Re: sharing variables-data perl-asp
    ... Also how do you invoke a perl script from an active server page? ... ASP in Perl. ... Why do you want to shell out to perl when you're already running perl? ...
    (comp.lang.perl.misc)
  • Re: environment variables in perl scripts
    ... Define a BEGIN block in your perl program. ... > perl script, something like: ... > environment variables are there and diag.txt shows ... > This communication is intended for the use of the ...
    (perl.dbi.users)
  • Re: kill process when file count reached,,.
    ... an infinite loop there, ... IMO you could just use readdir and grep in perl. ... You're using awk in backticks in a perl script? ... Perl has a kill builtin, why the hell not use that. ...
    (comp.lang.perl.modules)