in reply to value uninitilized when using Parallel::ForkManager module

It seems to me that this code line:
($pwm_count_hash->{$pwm}) = count_pwm_num($pwm,$seq_1,$seq_2);
is never executed, because of the next instruction of the previous line (unless $pm->start fails).

Je suis Charlie.

Replies are listed 'Best First'.
Re^2: value uninitilized when using Parallel::ForkManager module
by afoken (Chancellor) on Apr 14, 2015 at 16:07 UTC
    It seems to me that this code line: $pwm_count_hash->{$pwm}) = count_pwm_num($pwm,$seq_1,$seq_2); is never executed, because of the next instruction of the previous line (unless $pm->start fails).

    This is how Parallel::ForkManager works: $pm->start hides a fork() call and returns true (the child's PID) in the parent process and false in the child process. $pm->start and next makes sure that all following code is executed only in the child process, $pm->finish() at the end of the loop hides exit() and makes sure that the loop is executed only once in the child process. (Actually, Parallel::ForkManager does a little bit more. See the documentation.)

    Alexander

    --
    Today I will gladly share my knowledge and experience, for there are no sweeter words than "I told you so". ;-)
      Thank you very much for the information, afoken, I did not know, because I never used Parallel::ForkManager, but I should probably have guessed something like that, since I wrote forking programs, albeit quite sometime ago and not in Perl.

      Je suis Charlie.