Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!sdd.hp.com!samsung!rex!ukma!usenet.ins.cwru.edu!ncoast!allbery From: allbery@NCoast.ORG (Brandon S. Allbery KB8JRR) Newsgroups: comp.lang.perl Subject: Re: Help with op.exec test Message-ID: <1991Jan30.175029.8619@NCoast.ORG> Date: 30 Jan 91 17:50:29 GMT References: Reply-To: allbery@ncoast.ORG (Brandon S. Allbery KB8JRR) Followup-To: comp.lang.perl Organization: North Coast Public Access Un*x (ncoast) Lines: 30 As quoted from by jb3o+@andrew.cmu.edu (Jon Allen Boone): +--------------- | My question is "what is the purpose of op.exec?" That is to say, what | is it testing? For instance, test 1 is: +--------------- The Perl features which use the exec system call. +--------------- | print "not ok 1\n" if system "echo ok \\1"; # shell interpreted | | why is perl not ok if a system call "echo ok \\1" works? +--------------- The "system" function in Perl doesn't return true/false; it returns the commands's exit status, which is 0 if the command *succeeded*. So you have to "reverse" the sense of what you're testing for, just as you must in C --- to see if it failed, you must test for what would normally be SUCCESS. Larry's fond of fast idioms. A more readable (but slower) version of the test is: print "not ok 1\n" unless system("echo ok \\1") == 0; ++Brandon -- Me: Brandon S. Allbery VHF/UHF: KB8JRR on 220, 2m, 440 Internet: allbery@NCoast.ORG Packet: KB8JRR @ WA8BXN America OnLine: KB8JRR AMPR: KB8JRR.AmPR.ORG [44.70.4.88] uunet!usenet.ins.cwru.edu!ncoast!allbery Delphi: ALLBERY