in reply to Re: passing argv by reference
in thread passing argv by reference

I seem to have asked the question incorrectly. spawn_proc_prog will spawn (like the "system" call) the program specified in $command and send it arguments in the argv array. What I want to do is read the content of the argv array in the program that receives it (the one in $command), and $r is the apache request object...

My usage looks something like :

$command = "foo.pl";
@args = qw(1 2 3 4 5);
spawn_proc_prog($r, $command, \@argv);


Now I want to be able to read the argv array in foo.pl. I get the referent, but it arrives as an empty array...

Thanks
- BGa

Replies are listed 'Best First'.
Re: Re: Re: passing argv by reference
by bobn (Chaplain) on Jun 09, 2003 at 21:21 UTC
    Since it's being handled as a command, did you look in @ARGV of foo.pl?

    This is reinforced by the module doc that says:
    The third optional argument is a reference to an array which if passed becomes ARGV to the spawned program.


    --Bob Niederman, http://bob-n.com
Re: Re: Re: passing argv by reference
by Anonymous Monk on Jun 09, 2003 at 21:13 UTC
    I don't think perl automagically will allow two (or more) processes to read and write to the same memory. The solution? Look into the IPC::Shareable module. It provides routines to tie variables to Shared memory, and lock and unlock access to avoid race conditions. If I get some time I'll post sample code.