I have to debug an old perl script which, apparently, is setting the version of perl in a way which I do not understand...
: # use perl
eval 'exec perl -S $0 ${1+"$@"}'
if 0;
perl -h says that -S means "look for programfile using PATH environment variable". $0 is the current program. And I've read that $@ means "The Perl syntax error message from the last eval command." But why are they adding 1 to that ? And how does this all fit together ? What is it doing?
Part of what I have to debug has to do with the fact that it's picking an older version of perl that I don't want. For everything else, we use #!/usr/bin/env perl which, I suspect, may be doing the same thing. I also suspect that my solution may lie in fixing $PATH (or preventing the code that's goofing it up from goofing it up). But I'd like to go at this with a better understanding of how it's picking the version now.
Thanks for any help !