in reply to Re: i cant see whats wrong with this:
in thread i cant see whats wrong with this:

really? i used the  if(cond){block}else if(...){...} construction in several perlscripts and there, they worked just fine.
but i'll try it your way. thx...
--> it seems to work....

Replies are listed 'Best First'.
Re: Re: Re: i cant see whats wrong with this:
by BrowserUk (Patriarch) on Aug 30, 2002 at 09:07 UTC

    Directly from perlman:perlsyntax manual.

    The following compound statements may be used to control flow: if (EXPR) BLOCK if (EXPR) BLOCK else BLOCK if (EXPR) BLOCK elsif (EXPR) BLOCK ... else BLOCK LABEL while (EXPR) BLOCK LABEL while (EXPR) BLOCK continue BLOCK LABEL for (EXPR; EXPR; EXPR) BLOCK LABEL foreach VAR (LIST) BLOCK LABEL foreach VAR (LIST) BLOCK continue BLOCK LABEL BLOCK continue BLOCK

    Do you see a syntax diagram for

    if(cond){...} else if(cond) {...} else {...} there anywhere?

    Sorry! I don't know what language you were using, but it wasn't Perl!


    Well It's better than the Abottoire, but Yorkshire!
      you're right,

      i used this syntax, due to my c++ and java knowledge (although there would be a switch - case statement in use...).
      i believed that i got this structure also in other perlscripts.
      as i checked it, i saw, that i've had this prob earlier and solved it with a rather ineffective workaround...

      thanks again, now it works just fine!
      m.t.minded

        Your welcome!

        And don't worry, you aren't the only one. I still do this every now and again. Actually, nearly everytime I type an elsif it comes out as  else if or elif when I first type it. It's become almost automatic to go back and correct it as I go, before I ever attempt to run the code.

        Human brains are weird things. It seems to take an age to learn something, but un-learning it is oh, so much harder.