On Thu, Jan 02, 2003 at 12:56:46PM -0600, Jensen Kenneth B SrA AFPC/DPDMPQ wrote:
> In reading messages on this list I've picked up some snippets like
> 
> 'do some code here' if (condition);
> 
> Can the same be done if you have an if statement like this
> 
> If (condition){
>   print "hi";
>   $somevar++;
> }
> 
> Or can you only have 1 command preceding the if?
> 
> I tried
> 
> Print "hi" $somevar++ if (condition);  #compile error
> Print "hi" | $somevar++ if (condition); #compiles but $somevar++ does not
> increment

Yes, it does, but you print out the bitwise or of "hi" and $somevar.

> Print "hi" || $somevar++ if (condition); #compiles but $somevar++ does not
> increment
> Print "hi" && $somevar++ if (condition); #compiles but $somevar++ does not
> increment

Again, it does, but you print out ("hi" && $somevar) which is optimised
away to $somevar

You are looking for the comma operator, though maybe you shouldn't be.

print("hi"), $somevar++ if (condition);

-- 
Paul Johnson - [EMAIL PROTECTED]
http://www.pjcj.net

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to