Dec 1, 2003, 7:39 AM
Post #8 of 8
Re: [madhu_p] " IF " Statments ..
[In reply to]
Iam sorry ,iam wrong 'else 'will not have condition but I think 'else' will follow 'elsif'(ref:programming perl O'reilly : page no:94)
Please include the edition number when referencing pages in books as they can change between editions. Page 94 of the most recent (3rd) edition has nothing to say about if, elsif or else. But on page 113 it has the following examples of compound logical statements:
if (EXPR) BLOCK
if (EXPR) BLOCK else BLOCK
if (EXPR) BLOCK elsif (EXPR) BLOCK ... else BLOCK
Which does, I confess, imply that an "elsif" block must have a following "else" block, but it's not true. As simple experimentation would have shown. The "else" block is _always_ optional.
I'll submit a patch to the documentation.
Dave Cross, Perl Hacker, Trainer and Writer
Get more help at Perl Monks