Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re: How can I run a piece of code asyncronously in Perl?

by aitap (Deacon)
on Nov 02, 2012 at 19:25 UTC ( #1002031=note: print w/replies, xml ) Need Help??


in reply to How can I run a piece of code asyncronously in Perl?

TIMTOWTDI:
if (fork==0) { exec qw{t1.pl arg1 arg2 arg3}; }
This will fork the program and start your command in the child process (where fork returns 0).
Sorry if my advice was wrong.

Replies are listed 'Best First'.
Re^2: How can I run a piece of code asyncronously in Perl?
by Anonymous Monk on Nov 03, 2012 at 19:04 UTC

    This TIMTOWTDI is probably better than the other WTDI. But I'd like to make it clear to the OP that exec() takes a list, so therefore:

    exec 't1.pl', $arg1, $arg2, $arg3;

    (Well, better in the sense that I cringe whenever something goes through sh -c when not absolutely necessary. It is very easy to introduce a bug that way.)

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1002031]
help
Chatterbox?
[marioroy]: erix are you using csh
Discipulus uh the link was for cmd.exe the bash one
[marioroy]: If yes, for redirection to work, one might do the following
[marioroy]: `bash -c "clang --version 2>/dev/null"`
[choroba]: Sane people don't use csh
[marioroy]: the 1>&2 will work, not shown
[marioroy]: sorry, did not know which if cmd.exe or unix (bash)
[choroba]: csh considered harmful
[erix]: no, I'm using bash :)
[marioroy]: :)

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (9)
As of 2017-03-23 08:21 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Should Pluto Get Its Planethood Back?



    Results (284 votes). Check out past polls.