Adding the full path to perl.exe fixed the problem although perl is on the path environment variable.
The behaviour is strange because the earlier lines can find perl fine without prefixing the path.
Re^2: exec not working?
Replies are listed 'Best First'.
Did you close and restart whatever "session" you were running your scripts from following the Perl install and include path change? The session's version of the include path wouldn't be affected by any changes made outside the session or any changes made in child sessions.
Yes - definitely.
After some experimentation - and with careful changes to path environment - checking that path has been reloaded prior to running perl - I have found:
v5.12.0 will work.
v5.12.3 won't work.
In both cases I am reasonably confident that there is only one perl.exe on the path at any one time.
In both cases 'system' does work correctly with the same parameters as given to 'exec'.
I am not saying there is a bug - just commenting on my experience in my installation.
Note that the first system and the last exec statement are provided with identical arguments - the exec throws an exception but the same earlier call to system doesn't.
I do have a separate, older Perl installation - not on the path - which was not completely removed. When I installed the new Perl, I didn't un-install that Perl except I did remove it from the path. If I now change the path back to point at the older Perl build, I get the same broken behaviour of exec.
So the problem is my installation. If I want to fix it I may have to fully un-install both Perls.
I think the bug is in your code: exec does not honour the PATH variable (see exec - PATH isn't mentioned anywhere).
If you really want to use exec, give the full path (and the extension) of the perl.exe you want to use.