ramicio has asked for the wisdom of the Perl Monks concerning the following question:
That is just the flip-flop version I thought would work until I ran it and the first video was a long one (6 hours) and the rest were 1 hour videos. I also have been tinkering around with a test file and doing a sleep timer to simulate things:$slot = 1; my $pm = new Parallel::ForkManager( 2 ); foreach $key ( sort { lc $a cmp lc $b || $a cmp $b } keys %array ) { if( $slot == 2 ){ $slot = 1; } elsif( $slot == 1 ){ $slot = 2; } $pm->start and next; if( ! -e "/mnt/storage/videotemp/$key.hevc" ) { $cmd = 'WINEPREFIX=~/.wine64_'.$slot.' wine ... ; print "\n$cmd\n\n"; exec($cmd); } $pm->finish; } $pm->wait_all_children;
I just can't get that test file to kick back to slot one when it is told to. It seems like it is being evaluated correctly at the if statement, but after than it loses what $slotnow and $slot{#} were told to become. I really don't understand what is going on. Is there nothing that is a part of ForkManager to tell which slot is being used? Thank you.@data = ( 10,4,20,2,15,6 ); %slot = ( 'one' => 'unoccupied', 'two' => 'unoccupied' ); my $pm = new Parallel::ForkManager( 2 ); DATA_LOOP: foreach my $n (@data) { if ( $slot{ 'one' } eq 'unoccupied' ) { $slotnow = 'one'; $slot{ ' +one' } = 'occupied'; } elsif ( $slot{ 'two' } eq 'unoccupied' ) { $sl +otnow = 'two'; $slot{ 'two' } = 'occupied'; } $pm->start and next DATA_LOOP; print $slotnow." sleep($n)\n"; system( "sleep $n" ); #print "- $slot{$slotnow} - $n\n"; $slot{ $slotnow } = 'unoccupied'; #print Dumper( %slot ); $pm->finish; } $pm->wait_all_children;
|
|---|