in reply to Where is if...elsif...else documented in perldoc?
Note that, unlike C and Pascal, these are defined in terms of BLOCKs, not statements. This means that the curly brackets are required−−no dangling statements allowed. If you want to write conditionals without curly brackets there are several other ways to do it. The following all do the same thing: ...What more do you think needs to be said (apart from stating the obvious)?The "if" statement is straightforward. Because BLOCKs are always bounded by curly brackets, there is never any ambiguity about which "if" an "else" goes with. If you use "unless" in place of "if", the sense of the test is reversed.
Maybe it's a bit "off the beaten track" for this information to be in a section titled "Compound Statements", which begins with a definition of a BLOCK that is based on "scope", and an overview of what establishes a BLOCK. But it seems appropriate enough in terms of clarifying how conditional statements work in perl.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Where is if...elsif...else documented in perldoc?
by ELISHEVA (Prior) on Jun 26, 2009 at 05:31 UTC | |
by BrowserUk (Patriarch) on Jun 26, 2009 at 08:29 UTC | |
by Anonymous Monk on Jun 26, 2009 at 06:03 UTC | |
by ambrus (Abbot) on Jun 26, 2009 at 07:30 UTC |