in reply to YES you can! Re: setenv in perl
in thread setenv in perl

Corion observed that this can be done using only pure Perl. Which is right but somehow escaped me. So here it is in pure Perl. You still need to execute the script via exec env2.pl.

#!/usr/bin/perl # setenv from within perl to effect parent shell # actually parent should be more appropriately # called "adopted" or "step-parent", re execl # there is one little requirement: # you should run this program via shell's exec: # % exec <scriptname> # # this is pure-Perl implementation after Corion's # comment. # set env $ENV{test} = 'TURE'; # ... # this should be the last statement in your script # because nothing else will be executed after that # not even the 'or die ...' die "no shell!" unless defined($ENV{SHELL}); exec($ENV{SHELL}); __END__