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.