Solved

Running multiple SUB program at the same time

Posted on 2004-04-27
4
150 Views
Last Modified: 2010-03-04
Hi gurus


Is there a way to run multiple SUB progrmans at the same time in one PERL script ? Or do I need to make multiple PERL scripts ?

So let's asume that I have program:

----------EXSAMPLE---------------

#!/usr/bin/perl -w

use Net::FTP;

&FTP1;
&FTP2;
&FTP3;

----------END---------------


I need to run those sub scripts at the same time and I don't want to PERL ends with the firs FTP before moving to second one.


Thanks for any advise


- Jussi

0
Comment
Question by:salmjuh
  • 2
4 Comments
 
LVL 4

Expert Comment

by:vi_srikanth
ID: 10935926
U can try threading:

use Thread;
$th1=Thread->new(\&FTP1);
$th2=Thread->new(\&FTP2);
$th3=Thread->new(\&FTP3);
$retval=$th1->join();
$retval=$th2->join();
$retval=$th3->join();
0
 
LVL 4

Expert Comment

by:vi_srikanth
ID: 10935948
0
 
LVL 3

Accepted Solution

by:
PerlKing earned 50 total points
ID: 10945826
http://search.cpan.org/~bdarrah/Proc-ParallelLoop-0.5/lib/Proc/ParallelLoop.pm

Using this module, you can write a loop like a "foreach" loop. But the good thing is that all the iterations of the loop happen parallely. You can also specify the parallelism you need.
0

Featured Post

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

There are many situations when we need to display the data in sorted order. For example: Student details by name or by rank or by total marks etc. If you are working on data driven based projects then you will use sorting techniques very frequently.…
In the distant past (last year) I hacked together a little toy that would allow a couple of Manager types to query, preview, and extract data from a number of MongoDB instances, to their tool of choice: Excel (http://dilbert.com/strips/comic/2007-08…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now