in reply to How to make my script to more than one thing at once?

I feared Fork would be the answer. Having stared at the books a while it still doesn't make much sense. However I have a feeling that to do what I want I'd need to fork hundereds of times and I think that would be bad form.

I guess what I'm really after is a true 'fire and forget' entity which Perl doesn't have ('cos it's too responsible). Looks like I might have to use a batch script Yuk

I'd love to add another book to the shelf but I couldn't really justify it as I've still to read the ones I've got. I'll bare it in mind though if some kind sole suggests we need some more reference material.

Replies are listed 'Best First'.
Re: Re: How to make... - Thankyou people
by BrowserUk (Patriarch) on Aug 14, 2003 at 15:05 UTC

    fork works fine under Win32, but if you want to use system and don't want lots of CMD windows, just use the /B (for background) option on the start command and /c on cmd to make the cmd sessions 'go away' of their own volition.

    system( 'start /b cmd /c your_command' );

    If you have 5.8 then you can also use threads, the  async() function makes this very easy. The following line will do a dir for each subdirectory below your current directory asynchronously.

    use threads; async( sub{ system "dir $_" } ) for grep -d, glob '.\*';

    Not a very convincing demo, but it does work.


    Examine what is said, not who speaks.
    "Efficiency is intelligent laziness." -David Dunham
    "When I'm working on a problem, I never think about beauty. I think only how to solve the problem. But when I have finished, if the solution is not beautiful, I know it is wrong." -Richard Buckminster Fuller
    If I understand your problem, I can solve it! Of course, the same can be said for you.