|
[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]
|
Re: shebang pointing to script?
|
I _think_ I've figured out what you're trying to get at. Or.. I may
be completely off the bat.
You're expecting $0 to be equivalent to C's argv[0] -- but it's not.
They are similar and have some of the same capabilities, but are different.
(from perlvar.pod)
$0 Contains the name of the file containing the Perl
script being executed. On some operating systems
assigning to "$0" modifies the argument area that
the ps(1) program sees. This is more useful as a
way of indicating the current program state than
it is for hiding the program you're running.
(Mnemonic: same as sh and ksh.)
--- t1.pl ---
#!/usr/bin/perl
print "I am t1.pl -- but \$0 is $0\n";
--- t2.pl ---
#!/usr/bin/perl
exec './t1.pl' '-george';
--- t3.pl ---
#!/usr/bin/perl
exec './argv0' '-george';
--- argv0.c ---
#include <stdio.h>
int main(int argc,char **argv) {
printf("argv[0] = %s\n",argv[0]);
}
./t1.pl -->
I am t1.pl -- but $0 is ./t1.pl
./t2.pl -->
I am t1.pl -- but $0 is ./t1.pl
./t3.pl -->
argv[0] = -george
So... I don't think you can do what you want with $0.
It's also exec, which will actually replace the current process with
the new one. So it's actually starting up a completely new
/usr/bin/perl process.
Maybe what you want can be achived with C< do >?
-R
**Majordomo list services provided by PANIX <URL:http://www.panix.com>**
**To Unsubscribe, send "unsubscribe phl" to majordomo@lists.pm.org**
|
|