Cheburashka has asked for the wisdom of the Perl Monks concerning the following question:

... if(!system("$program>$seq_file")) { //error } ...
I recently had to port some perl script to a unix machine and it calls an executable at some point via a C program. It works, but... SYSTEM does not return 0 as it's supposed to when execution is successful. I don't know why. Some things I thought about: a) Maybe I need to flush befare calling system? I used the line I got from perl.com documentation:
select((select(STDIN), $| = 1) [ 0 ]);
but it didn't help. b) Another thing I thought...was maybe there is a timeout for the SYSTEM cal I am not aware of? The program takes about .5 seconds to execute. I could use any help or suggestions. Thanx fuzzy animals unite!!! Cheb

Replies are listed 'Best First'.
Re: SYSTEM call on windows misbehaves
by Ido (Hermit) on Feb 26, 2002 at 18:50 UTC
    System, as you said, returns 0 when execution is successful. Therefore the lines:
    if(!system("$program>$seq_file")) { # not //;) error }
    Aren't correct. Because When the return of system is false, as you check in the condition, there's no error. I think you should drop the !..
      by god you are right...that's what I get for using other people's scripts...thanks a lot.