Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Re^2: How do I set env. Variables from Perl with shell script

by Noame (Beadle)
on May 05, 2009 at 12:53 UTC ( [id://761924]=note: print w/replies, xml ) Need Help??


in reply to Re: How do I set env. Variables from Perl with shell script
in thread How do I set env. Variables from Perl with shell script

Thanks All.
Finally have written the following codes:
my $HOME = $ENV{HOME}; my $shell = shift || (getpwuid($<))[8]; my $command = "${HOME}/.project_setup"; my @setup = `$shell -c \". $command ; env\"`; foreach (@setup) { if (/^(\S+)=(.*)$/) { my ($key, $value) = ($1, $2); #print ("$key => $value\n"); $ENV{$key} = $value; } } print "$ENV{INCLUDE}\n";

Replies are listed 'Best First'.
Re^3: How do I set env. Variables from Perl with shell script
by linneighborhood (Initiate) on Nov 06, 2009 at 10:51 UTC
    I am a bit confused or may be dont understand, but how you are passing HOME variable here in perl script from that shell script.
      Its already defined in %ENV
      perl -MData::Dumper -le"print Dumper(\%ENV)"
Re^3: How do I set env. Variables from Perl with shell script
by Anonymous Monk on Jun 01, 2009 at 15:15 UTC
    Noame, I'm a bit confused at this code. Would you please give an example using the PERL5LIB=/my1stdir/my2nddir/lib as the environmental variable in the code. Many thanks ...

      About what part of Noame's code are you confused? Perlmonks is not a code writing service.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://761924]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others browsing the Monastery: (2)
As of 2024-06-14 22:29 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?
    erzuuli‥ 🛈The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.