mnlight has asked for the wisdom of the Perl Monks concerning the following question:

Is it posible to call a subroutine before one is finihed. I am adding rows to a database through the bcp process. while the rows are added I would like to continuously check the available space in the db then alter it if necessary. Is this possible. Everyting I read about fork or exec tell me it makes the other process wait.
  • Comment on running multiple sub routines at the same time

Replies are listed 'Best First'.
Re: running multiple sub routines at the same time
by revdiablo (Prior) on Apr 21, 2005 at 19:05 UTC
    Everyting I read about fork or exec tell me it makes the other process wait.

    fork and exec are very different things. They are frequently used in conjunction, but grouping them together as you have only confuses the issue.

    If you are talking about fork, then no, it does not "make the other process wait." In fact, it is designed specifically to allow you to do two things at the same time. You can probably accomplish your task with a forked process watching the db size, though it might not be the easiest solution.

    If you meant exec, well, then perhaps your statement applies. Though it's worth pointing out that exec doesn't "make the other process wait" so much as "take over completely." That is, when you exec something, that thing takes over the process and you never get control back.

    Notwithstanding the fact that fork can probably do what you want, the simplest solution is probably something along the lines of that suggested by dragonchild.

Re: running multiple sub routines at the same time
by dragonchild (Archbishop) on Apr 21, 2005 at 18:50 UTC
    Break the datafiles you're passing to bcp into smaller chunks. You can then check for space between each chunk.

    Alternatively, you can have another process that monitors the database separately and increases space while the bcp is still running.

Re: running multiple sub routines at the same time
by sk (Curate) on Apr 22, 2005 at 03:37 UTC