I have a problem in pre-pending to PATH for a captive script. I'm trying to append the location of the perl executable I wish to use to the beginning of the PATH and then exec it to pick up the change. Since this perl script is called directly in a captive environment I am unable to set these environment variables in calling script first. This method works fine for other environment variables (I picked this code up from a response to another question by Tye) but not for the PATH.
# Set up the perl executable and library path
BEGIN {
$ENV{PATH} = "/mypath/perl/bin:$ENV{PATH}";
$ENV{PERL5LIB} = '/mypath/perl/lib/site_perl/5.8.8/sun4-solari
+s:/mypath/perl/lib/site_perl/5.8.8:/mypath/perl/lib/site_perl:/mypath
+/perl/lib/5.8.8:/mypath/perl/lib/site_perl';
exec 'env', $^X, $0, @ARGV;
}
The problem is that when I do the above the executable never returns and I cannot figure out what it is doing. I suspect it is constantly re executing itself in an infinite loop
Any help appreciated