Re: Where is the interpreter
by ikegami (Patriarch) on Jan 08, 2007 at 03:08 UTC
|
>perl -le "print $^X"
c:\Progs\perl588\bin\perl.exe
| [reply] [d/l] [select] |
|
|
| [reply] |
|
|
The warning makes no sense in that situation. It tells you to use a copy of Perl that's known to be safe instead of relying on $^X, while the OP's problem is that he doesn't know where his Perl is located.
The warning applies to the method used in your solution too. In fact, it applies to all answers to the OP's question other than those that match the pattern "I talked to your service provider and they told me to use the Perl located in XXX."
Furthermore, if the OP made a copy, he probably wants to use that copy (especially if he patched it).
The usual case for using $^X is to spawn a subprocess. The warning applies to launching child processes from setuid scripts (or code that might find its way into one).
| [reply] [d/l] [select] |
Re: Where is the interpreter
by shigetsu (Hermit) on Jan 08, 2007 at 00:36 UTC
|
This functionality has been portably implemented by Per Einar Ellefsen.
See File::Which for the details.
Example code for Unix:
#!/usr/bin/perl
use strict;
use warnings;
use File::Which qw(which where);
my $path = which('perl');
my @paths = where('perl');
| [reply] [d/l] |
Re: Where is the interpreter
by Joost (Canon) on Jan 08, 2007 at 00:17 UTC
|
which perl
at the command line. On windows the actual path doesn't matter as far as I know (but you need to associate the .pl extension with the perl binary).
| [reply] [d/l] |
|
|
Well, the Apache installation for Windows is a bit different. It is not looking at file associations. If you screw up the shebang even if it is Windows, it will not run correctly.
| [reply] |
Re: Where is the interpreter
by kwaping (Priest) on Jan 08, 2007 at 01:22 UTC
|
How about this (adapted from perlvar):
use Config;
my $perl_with_path = $Config{perlpath};
---
It's all fine and dandy until someone has to look at the code.
| [reply] [d/l] |
Re: Where is the interpreter
by NetWallah (Canon) on Jan 08, 2007 at 00:28 UTC
|
Assuming your install script is in perl, the following should work on both systems (Tested OK on Win32):
my $p;
for (split /,|;/, $ENV{PATH}){
m/\Wperl\W/i and $p=$_
};
print qq[===$p==\n]; # $p contains the path to perl
Admittedly, if you have perl-like paths in the PATH, this code would be confused - but then you could get fancy, and try to verify existance of perl, and it's execute-ability.
Update:Ignore this drivel. Use ikegami's (++) correct answer below.
"A closed mouth gathers no feet." --Unknown
| [reply] [d/l] |
Re: Where is the interpreter
by randyk (Parson) on Jan 08, 2007 at 04:06 UTC
|
As an alternative on Windows, you can also use the Apache
ScriptInterpreterSource directive - this searches the Registry by script file extension to discover which command to use. | [reply] |
Re: Where is the interpreter
by bart (Canon) on Jan 08, 2007 at 11:09 UTC
|
On Windows, you can just use
#! perl
As long as perl is found in the path, it'll work. I'm not convinced it even needs to be in the path. An incorrect path will not work, Apache won't like it. | [reply] [d/l] |
Re: Where is the interpreter
by WiseGuru (Initiate) on Jan 08, 2007 at 00:19 UTC
|
not sure of windows, but do a search of files for the perl folder, and it usualy looks like #!/(full path to folder/perl
the folder name might vary, but in general there is a way to find it, you gotta do a google search or someone else here give you the windows command to find it!
there will be several folders, like perl, perl5.8.. perl4....
here is where i believ the she-bang points in general, point it to the main folder, as pointing it to your latest install will be useless when you upgrade, and you have to change all your scripts to accomodate!
www.arobcorp.com | [reply] |
|
|
I am writing an automatic installation, not a manual installation.
I would like a programmatic solution because I will be giving the installation to people who may or may not have the expertise to figure out where the interpreter is located and the application maybe in Windows or UNIX so it has to be flexible.
| [reply] |
|
|
in that case your writing a ".exe" right?, then you gotta get the ".exe" to search the file system for the appropriate file, then include it in the installed file, simular to when some programs instal, they go off and look for the nessary system files they need (i.e. fonts,sound,drives etc) then add them to the pre-install file, then once all found and no errors, instal the pre-install file!
so, you gotta find the general folder, then the ".exe" has to include it in the instal!
| [reply] |
Re: Where is the interpreter
by ikegami (Patriarch) on Jan 08, 2007 at 17:05 UTC
|
If you're still having the problem, why don't you ask your web hosting service (if the box is remote) or whoever installed Perl for you (if the box is local). | [reply] |
Re: Where is the interpreter
by MaxKlokan (Monk) on Jan 08, 2007 at 09:45 UTC
|
For UNIX you can use the following shebang (from perlintro), and it should work regardless of where the interpreter is, provided that it is in the path:
#!/usr/bin/env perl
As far as I know env should be always in the same place. | [reply] [d/l] |
|
|
| [reply] [d/l] [select] |