in reply to Re^9: adding a hash to a shared object
in thread adding a hash to a shared object

Each subroutine is called once, but I want to parallelize the calls for the different subroutines. Suppose sub1 takes a minute to run and so does sub2, and the do not depend on each other, so I can run them concurrently.
  • Comment on Re^10: adding a hash to a shared object

Replies are listed 'Best First'.
Re^11: adding a hash to a shared object
by Corion (Patriarch) on Aug 11, 2010 at 13:41 UTC

    I'm confused. First you say:

    My perl script is used to run some kind of a pipeline. I start by reading a JSON file with a bunch of parameters in it. I then do some work - mainly building some data structures needed later and calling external programs that generate some output files I keep references to.

    ... but now you say the subroutines don't use any common data. I think I need more explanation, as to which is what your actual situation is.

    If your subroutines don't need any common data, consider making them into separate programs, or simply running them in separate threads (if you really want to use threads, which I would want to avoid, then). If your subroutines depend on data prepared by each other, make them communicate through queues. If your subroutines depend on data read by the main program, feed each subroutine its data through a queue.

      I'm sorry for the confusion. My subroutines do use common data. Some of them use data read by the main program, some of them use data prepared by each other, and most of them use both kinds of data.