How do I know which perl I use when running a script with '/ usr / bin / env perl'?

Using shebang, like #!/usr/bin/env perl , how can I make available to the Perl script that I use to run the script?
(Like the command line perl -E 'say $ENV{_}' ).

+4
source share
3 answers

There is a $^X variable in perlvar that you could use.

 $ perl -e 'print $^X, "\n";' /usr/bin/perl5.12.4 
+7
source

Use $^X

+3
source

$^X is what you can usually look at

 $ perl -E'say $^X;' /home/ikegami/usr/perlbrew/perls/5.14.2t/bin/perl 

Unfortunately, it does not contain an absolute path for some systems. (I donโ€™t know why. Maybe because the exact information is not available on these systems?) Probe :: Perl find_perl_interpreter works a lot to find the absolute path if $^X does not contain the absolute path.

 $ perl -MProbe::Perl -E'say Probe::Perl->find_perl_interpreter();' /home/ikegami/usr/perlbrew/perls/5.14.2t/bin/perl 
+2
source

Source: https://habr.com/ru/post/1395250/


All Articles