No, Win32 Perl has never figured out $^X based on argv[0]
I freely admit to being very new to reading the Perl source (what's that line about 'a maze of twisty passages'?) but what about this excerpt from perllib.c around the line you quoted (for Perl 5.8.8 anyway):
EXTERN_C DllExport int
RunPerl(int argc, char **argv, char **env)
{
int exitstatus;
PerlInterpreter *my_perl, *new_perl = NULL;
#ifndef __BORLANDC__
/* XXX this _may_ be a problem on some compilers (e.g. Borland) th
+at
* want to free() argv after main() returns. As luck would have i
+t,
* Borland's CRT does the right thing to argv[0] already. */
char szModuleName[MAX_PATH];
GetModuleFileName(NULL, szModuleName, sizeof(szModuleName));
(void)win32_longpath(szModuleName);
argv[0] = szModuleName;
#endif
It looks like win32 Perl fixes up argv[0] itself -- and that this is what is used later by S_set_caret_X (a new function as of 5.8.7).
However, that perllib.c line is a great find for Vanilla Perl -- it means we should be able to use relocatable perl pretty easily in most circumstances. (I'm not going to worry about mod_perl on win32 at first.)
The downside is that the expansion uses the full path -- including spaces if installed somewhere like "C:\Program Files\Perl". That will still be problematic for people who call system("$^X program.pl arg1 arg2 etc") as the shell is going to have problems as the program name is not quoted. Of course -- that's not really a portable call anyway, so maybe we tackle that problem with documentation.
-xdg
Code written by xdg and posted on PerlMonks is public domain. It is provided as is with no warranties, express or implied, of any kind. Posted code may not have been tested. Use of posted code is at your own risk.
|