in reply to Re: Problem with forking in perl
in thread Problem with forking in perl

How can I overcome this? How to seperate these variable..? also LoginDB subroutine creates DB connection handle for the child process.

Replies are listed 'Best First'.
Re^3: Problem with forking in perl
by McA (Priest) on Mar 14, 2013 at 09:07 UTC

    There are two possibilities

    • Change the parameters, so that the only list assignment is at the end.

      sub ProcessRecords() { my ($myNbr, $totalChilds, $totalAccts, @acctArray) = @_;
      In this case the scalars get one value and the rest is slurped by @acctArray. The sequence of parameters has also to be changed at the calling point.

    • Or you use references:

      sub ProcessRecords() { my ($ref_acctArray,$myNbr,$totalChilds,$totalAccts) = @_;
      and call it with
      ProcessRecords( \@SharedPlanAccts, $i1, $n, $totalAccts );
      You than have to dereference $ref_acctArray with a @$ref_acctArray.

    McA