in reply to Switching back and forth between parts of my script

Thank you all (Laurent R, perlfan, Tanktalus) for your ideas! Tanktalus, I think you misunderstood my arrays' schema, but no matter: I think I will end up using something based directly on one of your ideas:

while(@array1 or @array2) { while(@array2) { my $item = shift @array2; # Do various things } if(@array1) { my $item = shift @array1; # Do various things } }

This avoids the need for me to learn to use threads or Coro. And (it's especially good for me at this juncture. My script has (as I mentioned) been running for days, building up `@array2` without doing anything with it really, but I stored the array elements in a file, so now I can read that file and start acting on it immediately. Even after my current list of `@array2` items is exhausted,) I'm more interested really in `@array2` items than in `@array1` items, so this is a good solution for me. Thanks again.

$_="msh210";$"=$\;@_=@{[split//,uc]}[2,0];$_="@_$\1";$\=$/;++$_[0]for$...1;print lc substr crypt($_,"@_"),1,6

Replies are listed 'Best First'.
Re^2: Switching back and forth between parts of my script
by perlfan (Parson) on Mar 07, 2016 at 21:51 UTC
    Cool. The only thing I was addressing in my solution of % chance is the concept of process "fairness;" clearly it doesn't address priority.