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

for (@y) should be for my $liney (@y)

Replies are listed 'Best First'.
Re^4: Variables loop in Parallel::ForkManager
by jackyex (Initiate) on Nov 30, 2008 at 08:22 UTC
    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

      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);
      That's my understanding of what you wanted. What output do expect from cat 1 and cat 2?