http://www.perlmonks.org?node_id=1007605


in reply to start up process without waiting

Your problem description is a little obtuse to me; code is worth 1k words. See How do I post a question effectively?.

One possible solution to your issue as I understand it would be to fork or use threads. Which you pick depends on a lot of particulars of what you intend to do while the files are open and once the files are closed. Using a fork and exec might look like:

$SIG{CHLD} = "IGNORE"; for my $file (@files) { exec $file unless fork; }

#11929 First ask yourself `How would I do this without a computer?' Then have the computer do it the same way.

Replies are listed 'Best First'.
Re^2: start up process without waiting
by exilepanda (Friar) on Dec 06, 2012 at 15:35 UTC
    alright, thank you...
Re^2: start up process without waiting
by exilepanda (Friar) on Dec 06, 2012 at 16:10 UTC
    thanks for your updated with code demonstration. However I think there's no fork for windows. Anyway, I just resolved this in more shell way:
    `start /B /I "" "$file"`;

      While there is no fork() system call on Windows, your version of perl was likely built to emulate it using threads; thus the code I provided will work -- and was, in fact, tested on a Windows XP machine. See fork, perlfork and/or fork in perlport.


      #11929 First ask yourself `How would I do this without a computer?' Then have the computer do it the same way.

      Also, as you are tossing away your return values, you should not be using backticks. Not only is your intent misleading, using system also buys you automatic escaping if you use the multiple argument form:

      for $file (@files) { system 'start', '/B', '/I', '', $file }

      #11929 First ask yourself `How would I do this without a computer?' Then have the computer do it the same way.