CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Beginner:
same sub multiple times at once?

 



lukdk
Novice

May 4, 2017, 12:03 PM

Post #1 of 6 (326 views)
same sub multiple times at once? Can't Post

Hello,

Do you have links to tutorials explaining how I can execute the same sub multiple times at once?
I've looked a bit online and found solutions on forums explaining fork or use:threads but not really a good explanation / tutorial.

something like
foreach ($line, @file){
do some commands, but do them with 20 lines at a time
}
wkr,
Luk


(This post was edited by lukdk on May 4, 2017, 12:12 PM)


FishMonger
Veteran / Moderator

May 4, 2017, 1:15 PM

Post #2 of 6 (316 views)
Re: [lukdk] same sub multiple times at once? [In reply to] Can't Post

Take a look at:
Parallel::ForkManager - A simple parallel processing fork manager
http://search.cpan.org/~yanick/Parallel-ForkManager-1.19/lib/Parallel/ForkManager.pm

IO::Async - Asynchronous event-driven programming
http://search.cpan.org/~pevans/IO-Async-0.71/lib/IO/Async.pm

AnyEvent - the DBI of event loop programming
http://search.cpan.org/~mlehmann/AnyEvent-7.13/lib/AnyEvent.pm

The first one is probably the easiest to work with.


FishMonger
Veteran / Moderator

May 4, 2017, 1:48 PM

Post #3 of 6 (312 views)
Re: [lukdk] same sub multiple times at once? [In reply to] Can't Post

Google search -> site:youtube.com YAPC forking
https://www.google.com/search?q=site%3Ayoutube.com+YAPC+forking&ie=utf-8&oe=utf-8


Laurent_R
Veteran / Moderator

May 4, 2017, 2:33 PM

Post #4 of 6 (310 views)
Re: [lukdk] same sub multiple times at once? [In reply to] Can't Post

In addition to the suggestions made by FishMonger, you might also want to take a look at MCE (Many-Core Engine): http://search.cpan.org/~marioroy/MCE-1.829/lib/MCE.pod

I haven't used it personally, but I have seen good reviews and very positive comments on it.


lukdk
Novice

May 6, 2017, 11:32 AM

Post #5 of 6 (299 views)
Re: [Laurent_R] same sub multiple times at once? [In reply to] Can't Post

what does this mean?


my $pm = Parallel::ForkManager->new($MAX_PROCESSES);


it's the arrow command i'm not understanding.
it's declaring a var with name $pm, which gets the value of a result of a sub called from a module declared with the use command but then the arrow?

maybe a link to another manual? :) guess my first question was too hard for me to understand the answers :)


(This post was edited by lukdk on May 6, 2017, 11:44 AM)


BillKSmith
Veteran

May 6, 2017, 1:21 PM

Post #6 of 6 (288 views)
Re: [lukdk] same sub multiple times at once? [In reply to] Can't Post

This statement uses perl's "object oriented" syntax.
Refer Object-Oriented Programming in Perl Tutorial
The variable $pm is an object, or more accurately, a reference to an object.
Good Luck,
Bill

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives