in reply to exec vs. system

system("swap.pl &") will put swap.pl into the background (a feature of the shell).

By the way, wouldn't it be easier to give the data as parameter to swap.pl, i.e. system("swap.pl \"$_\" &") ? This would only work for non-binary data naturally and you would have to escape " \ and $ in the string

Replies are listed 'Best First'.
Re^2: exec vs. system
by jpl (Monk) on Jul 07, 2011 at 17:39 UTC
    By the way, wouldn't it be easier to give the data as parameter to swap.pl, i.e. system("swap.pl \"$_\" &")? This would only work for non-binary data naturally and you would have to escape " \ and $ in the string.
    Not only easier, but more robust. Those of us who have been burned in almost every possible way cringe at the assumption that swap.pl will be done with the control file in less than one second, when it will be replaced by the control file for another instance. If the control data is too complex to pass as an argument, then give each control file a different name and pass the name to swap.pl as an argument.
Re^2: exec vs. system
by Microcebus (Beadle) on Jul 07, 2011 at 13:08 UTC
    Thanks for that reply but system("swap.pl &") seems not to put the process into the background. The master script still waits untill swap.pl is finished.
      Ah, so you probably are on Windows. At least I never heard of system(1,...) being sensible syntax, so probably this is an extension in your windows perl dialect
        I never heard of system(1,...) being sensible syntax, so probably this is an extension in your windows perl dialect.
        It would be sensible syntax if there were a command named "1" that ran its arguments on processor 1 in the background. I have to hope this is what's going on. Tampering with perl syntax would be too ugly to contemplate.