in reply to Need help getting correct syntax for "if" statement

Or there's always the conditional (ternary) method:
(index( $fl,'1')!= -1) ? $flag=1 : $flag=0;

Replies are listed 'Best First'.
Re: Re: Correct Syntax
by Sifmole (Chaplain) on Aug 09, 2002 at 12:40 UTC
    or you could do..
    $flag = (index( $f1,'1') == -1) ? 0 : 1;
    Dumps the extra "$flag"s and the negative conditional. Actually uses the returned value from the ternary.
      $flag = 0+(index( $f1,'1') != -1)