Created
March 25, 2013 14:20
-
-
Save kenelliott/5237436 to your computer and use it in GitHub Desktop.
Parallel ForkManager
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/perl | |
use Parallel::ForkManager; | |
use Data::Dumper; | |
$ENV{'foo'} = 'bar'; | |
my $pm = Parallel::ForkManager->new( shift ); | |
my $cnt = 10; | |
for ( 1 .. $cnt ) { | |
$ENV{'bat'} = 'baz'; | |
$pm->start and next; | |
&do_this; | |
$pm->finish; | |
} | |
$pm->wait_all_children(); | |
sub do_this { | |
print 'PID: '.$$.' Foo: '.$ENV{'foo'}.' Bar: '.$ENV{'bat'}."\n"; | |
} | |
1; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment