MissPerl has asked for the wisdom of the Perl Monks concerning the following question:
I wrote this simple script after some reading online.
To achieve fastest execution time, I want to have the number of jobs == arraysize. (any array in script for looping repeating process) I guess the other words, is instead of running stuff serially (one after the other), i have them in parallel to minimize time taken.
So in this case I wanna delete a directory, delete the directory1 in (/user/home/directory1/), but i am clueless why it does not work, all the files and subdirectories still there. Does the script automatically assign each files/subdirectories to each children?
Let me know if I have overlooked stuff. I am ready to learn . Thank you . :)
#! /usr/bin/perl use Parallel::ForkManager; $directory1 = "/user/home/directory1/"; my $pm = Parallel::ForkManager->new(10); my @files = glob("$directory1/*"); my $number = scalar(@files); for (my $i = 0; $i < $number; $i++) { $pm->start and next; system ("rm", "-fr", $files[i]); exit(0); $pm->finish; } $pm-> wait_all_children;
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Parallel::ForkManager for any array
by toolic (Bishop) on Oct 16, 2018 at 13:30 UTC | |
by MissPerl (Sexton) on Oct 16, 2018 at 13:51 UTC | |
Re: Parallel::ForkManager for any array
by 1nickt (Canon) on Oct 16, 2018 at 14:18 UTC | |
by Anonymous Monk on Oct 17, 2018 at 03:55 UTC | |
by 1nickt (Canon) on Oct 17, 2018 at 13:08 UTC | |
by MissPerl (Sexton) on Oct 17, 2018 at 15:11 UTC | |
Re: Parallel::ForkManager for any array
by ForgotPasswordAgain (Vicar) on Oct 16, 2018 at 17:18 UTC | |
by Anonymous Monk on Oct 18, 2018 at 00:26 UTC |