On Dec 14, 2007 9:00 AM,  <[EMAIL PROTECTED]> wrote:
> Thanks Jeff.
>
> How will this be considered.
>
> if(system(CondA) && system(CondB)) ...
>
> I am getting 0 as the $? RC...but goes to the else part of the if-statement. 
> Both the conditions (Unix commands are executed). Is it taking the CondB RC?
>

Manoj,

It is looking at both. The problem is that the shell executing the
system command returns zero on success, but 0 is *false* in Perl.

There are a couple of ways to get around this. One is to examine $? as
Jeff suggested. That is tricky with two system commands, since the
second will overwrite $? from the first. To get around that, you could
do something like the following to translate the shell return value
into a useful Perl boolean value:

    if ( (system(CondA) ? 0 : 1) && (system(CondB) ? 0 : 1) ) ...

The other thing would be to simply switch the conditional code, so
that what is currently in the else block is in the if block, and vice
versa.

HTH,

-- jay
--------------------------------------------------
This email and attachment(s): [  ] blogable; [ x ] ask first; [  ]
private and confidential

daggerquill [at] gmail [dot] com
http://www.tuaw.com  http://www.downloadsquad.com  http://www.engatiki.org

values of β will give rise to dom!

Reply via email to