sonic, do you have some reason to suspect it behaves differently? I don't have a Windows box to test on, but I strongly suspect it does the same thing it does everywhere else.
_______________
DamnDirtyApe
Those who know that they are profound strive for clarity. Those who
would like to seem profound to the crowd strive for obscurity.
--Friedrich Nietzsche
| [reply] [Watch: Dir/Any] |
Backticks (and qx) capture the child program's STDOUT and return it. system leaves STDOUT alone. That's the difference.
As for Win32, you might also reconsider using Win32::Process, as it allows you to not wait for a program to finish. It'll launch a program, any program, like the shell would do — in particular, itr's a good way to launch Windows programs (like notepad).
Other interesting appoaches, that work well on Win32 too, include IPC::Open2, IPC::Open3, and IPC::Run. I'm sure I'm still missing a few more, interesting, options. | [reply] [Watch: Dir/Any] |
Is there no way to do both--catch both the error code and the output of the called command?
| [reply] [Watch: Dir/Any] |
Well, you can use backticks/qx to capture the STDOUT, and check $? for the exit code — which agrees with what system returns ... check perlvar for details in $?.
| [reply] [Watch: Dir/Any] |
I can't think of a reference beyond Learning Perl, Perl Cookbook. I primarily use one or the other depending on what I need from the called program. Backticks will capture the STDOUT of the invoked program while system will return the exit status of the program. If I want the output, I use backticks, if all I need is the exit status, I use system. System does have one advantage over backticks in that you can spawn independant processes with system using the start command on windows, for example system("start $somepgm"). However, with backticks, start will not spawn an independant process. The calling program will wait until the called program exits. David Roths Win32 Perl Programming: The Standard Extenstions chapter 8 Processes, touches on this briefly but otherwise doesn't say much about it. I know that there are other ways of spawning processes, (fork, Win32::Spawn etc), but I like to keep things as simple as I can and backticks / system have worked for me so far. | [reply] [Watch: Dir/Any] [d/l] |