in reply to Re^2: How can I run a piece of code asyncronously in Perl?
in thread How can I run a piece of code asyncronously in Perl?
t won't work... Thread would be terminated, I suppose.
Why "suppose"? Did you try it?
C:\test>perl -Mthreads -E"async{ qx{perl -E\"sleep 5; die q[Now I'm do +ne];\"} }->detach; select'','','',0.1; die 'I\'m done'" I'm done at -e line 1. C:\test>Now I'm done at -e line 1.
So long as you give the thread chance to start the command running, it will complete even if the thread dies.
Ie. "t1.pl runs completely independently of t2.pl".
It's probably not how I would do it; but then 'it' -- as you've defined it so far -- is so completely pointless, I probably wouldn't do it at all.
But if I did, on Windows I'd probably use system 1, 't1.pl arg1 arg2 arg3';
|
|---|