in reply to ARGV empty when calling Perl from C program
Hi,
there is a little difference between C's argv and @ARGV in Perl. argv in C has a first element representing the program called while @ARGV in Perl is the list of arguments after the Perl script. Have a look at:
#include <stdio.h> int main(int argc, char* argv[]) { printf("argc %d\n", argc); if(argc > 0) { printf("arg1 %s\n", argv[0]); } return(0); }
In Perl the name of the called script is in $0. So the C equivalent in Perl would be:
my @CARGV = ($0, @ARGV);
Regards
McA
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: ARGV empty when calling Perl from C program
by Lotus1 (Vicar) on May 23, 2014 at 14:37 UTC | |
by Anonymous Monk on May 23, 2014 at 20:45 UTC | |
by Lotus1 (Vicar) on May 24, 2014 at 14:32 UTC | |
by RonW (Parson) on May 23, 2014 at 19:30 UTC | |
by Lotus1 (Vicar) on May 23, 2014 at 20:25 UTC |