in reply to Re^3: Variables loop in Parallel::ForkManager
in thread Variables loop in Parallel::ForkManager

Thank you,but :D it still doesn't work I did what you said but now it gives me the files like this : jacky@ubuntu:~/Desktop/test$ cat 1 1jack 1john 1joe jacky@ubuntu:~/Desktop/test$ cat 2 2jack 2john 2joe And so on...Any fix to this too? , Jack

Replies are listed 'Best First'.
Re^5: Variables loop in Parallel::ForkManager
by ikegami (Patriarch) on Nov 30, 2008 at 15:54 UTC
    That's my understanding of what you wanted. What output do expect from cat 1 and cat 2?
Re^5: Variables loop in Parallel::ForkManager
by ig (Vicar) on Nov 30, 2008 at 09:29 UTC

    The following might help. I don't understand why you are forking, so I have not done so, but you could add forking inside the loop if you want to, as long as you increment and reset $index_y in the main process so that it is coordinated across all the child processes.

    #!/usr/bin/perl use strict; use warnings; open(my $y, "<", "y") or die "y: $!"; my @y = <$y>; close($y); my $index_y = 0; open(my $x, "<", "x") or die "x: $!"; foreach (<$x>) { chomp; open(my $output, ">", "$_") or die "$_: $!"; print $output "$_$y[$index_y]"; close($output); $index_y++; $index_y = 0 if($index_y > $#y); } close($x);