Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

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

by jmcada (Acolyte)
on May 04, 2009 at 17:26 UTC ( [id://761777]=note: print w/replies, xml ) Need Help??


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

I wrote/use Env::Sourced one day when my cpan search foo was weak and I couldn't find any other alternatives. It should do what you need it to do.
  • Comment on Re: How do I set env. Variables from Perl with shell script

Replies are listed 'Best First'.
Re^2: How do I set env. Variables from Perl with shell script
by Noame (Beadle) on May 05, 2009 at 12:53 UTC
    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";
      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)"
      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://761777]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others having an uproarious good time at the Monastery: (3)
As of 2024-06-24 19:23 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.