http://qs1969.pair.com?node_id=517323


in reply to Doubts of a perl beginner on PERLEMBED

(2) My second question is about the third argument in "perl_parse".Some people put it as 2 or 3 or argc. I want to know what it actually means.
The third argument (argc) is simply the number of elements in the fourth argument (argv). This is an array of strings, which corresponds to the arguments you pass to perl on the command line.

In the examples in perlembed, some of them just pass their own command-line arguments through to the Perl interpreter, hence they pass their own argc and argv, while others use a constant array of arguments, and pass its length (which happens to be 3 in one of the examples, because the array is { "", "-e", "0" }, and 2 in another because the array is { "", "power.pl" }.)

(The first element of argv is more or less ignored, which is why these examples use the empty string. I imagine it's used to initialise $0, but I haven't confirmed that. It’s not even used to initialise $0.)

Update: changed ‘argument’ to the less ambiguous ‘element of argv’, in the last sentence.