Jerry Jerry - 4 months ago 9
Perl Question

how to know which perl interpreter is being used to execute current perl program

Suppose I have a script called

foo
and looks like below:

#!/bin/perl
eval 'exec perl5 -S $0 ${1+"$@"}'
if 0;


Based upon my understanding, if I run
perl foo
or
foo
, the system perl will be used to execute my script (i.e.
/usr/bin/perl
which is specified in shebang line). However, if I run my script
./foo
then the perl interpret being used is
perl5
inside
eval
statement.

I want to verify my theory and I need to find a way to find out which perl interpreter is invoked to execute my script.

Is there anyway to do so?

Thanks much!

Answer

yes, you can find the version of perl interpreter currently script executing in, using perl special veriable. $^V