Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

How to find which perl was used to invoke script

by tsk1979 (Scribe)
on Aug 21, 2009 at 05:42 UTC ( [id://790251]=perlquestion: print w/replies, xml ) Need Help??

tsk1979 has asked for the wisdom of the Perl Monks concerning the following question:

I have written a perl script, lets call it myscript.pl. It has lots of modules used, and sometimes customers do not have those modules installed. So a solution was adopted.
The software package(of which this script is a part) also provides a perl installation.
So I removed #!/usr/bin/perl from top of file, and changed use model to
$SOFTWARE_PATH/perl/bin/perl myscript.pl <option>
Now nothing stops user from doing
/usr/bin/perl myscript.pl
We don't want user to do that as the user installation may have older version of perl. So is there a way to check from inside myscript.pl, that what was the path from where perl was invoked? I searched google high and low, but could not find anything!
EDIT : I found it its $^X ! Went to a page with all perl special variables, theres quite a humongous list, and found this baby

Replies are listed 'Best First'.
Re: How to find which perl was used to invoke script
by laminee (Novice) on Aug 21, 2009 at 07:28 UTC
    A line like require 5.8.5; would restrict users from executing the script with Perl version lower than specified.
Re: How to find which perl was used to invoke script
by Boldra (Deacon) on Aug 21, 2009 at 07:53 UTC

    Great that you solved your own problem.

    Did you know you can get that page with all the special values by typing perldoc perlvar ? It's part of the standard perl documentation and available whenever perl is installed.

    And if you add the line use English; to the top of your program, you can call that variable $EXECUTABLE_NAME instead of the rather esoteric $^X. But if you do use English, it's a good idea to exclude some imports for performance. I have use English qw<-no_match_vars> in my template for new perl files.



    - Boldra
      Perl is esoteric.
      use Chinese;
      Hey, it doesn't work :p
        Hahhah :D that was good :)

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://790251]
Approved by rovf
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others cooling their heels in the Monastery: (3)
As of 2024-04-25 07:36 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found