#perl.exe -w # INIT ---- use strict; use Parallel::ForkManager; use MyTest; # Mind this one, it's the one that messes things up # VARS ---- my $max_procs = 10; my $wait = 5; my @collections = qw( adw adw_wet_compleet ag-dou ag-gi ag-hc ag-hlo ag-its-sol ag-its-sol-hot agents alg_diversen alg_dossier_juris_en_reso alg_ellis alg_ellis_en alg_kb alg_kfb alg_kluwer_rest alg_pdf alg_rest alg_sdu am b_adw b_adw_wet_compleet b_ag-dou b_ag-gi b_ag-hc b_ag-hlo b_ag-its-sol b_ag-its-sol-hot b_agents b_alg_diversen b_alg_dossier_juris_en_reso b_alg_ellis b_alg_ellis_en b_alg_kb b_alg_kfb b_alg_kluwer_rest b_alg_pdf b_alg_rest b_alg_sdu b_am b_bibliotheek b_bm b_bna-mix b_browsedocs b_curbel b_fmod b_help b_hvg b_hvg-kluwer b_mrp b_pz b_refdocs b_tss b_tss-pdf bibliotheek bm bna-mix browsedocs curbel fmod help hvg hvg-kluwer images mrp pz refdocs tss tss-pdf ); # MAIN ---- my $pm = new Parallel::ForkManager($max_procs); # Setup a callback for when a child finishes up so we can # get it's exit code $pm->run_on_finish( sub { my ($pid, $exit_code, $ident) = @_; print "** $ident finished (PID: $pid) and exit code: $exit_code\n"; } ); $pm->run_on_start( sub { my ($pid,$ident)=@_; print "** $ident started, pid: $pid\n"; } ); $pm->run_on_wait( sub { print "** waiting\n"; }, 0.5 ); foreach my $child ( 0 .. $#collections ) { my $pid = $pm->start($collections[$child]) and next; # This code is the child process print "Child: $collections[$child]\n"; sleep $wait; # End of child process $pm->finish($child); # pass an exit code to finish } print "Waiting for Children...\n"; $pm->wait_all_children; print "Everybody is out of the pool!\n"; #### package MyTest; #------------------------------------------------------------------------ # INIT #------------------------------------------------------------------------ use strict; use Win32::OLE; use Win32::OLE::Variant; 1;