Kenton Brede wrote:
> Does a compound statement need to end with an "else" ?

No.

> 
> I know  -
> 
> if (expression) {
>       statement;
> } elsif (expression) {
>       statement;
> }
> 
> works but I've never seen a block like that in a book yet.  I usually
> see something like - 
> 
> if (expression) {
>     statement;
> } elsif (expression) {
>     statement;
> } else {
>       statement;
> }

Either way is fine. If you leave off the "else" block and all the conditions
are false, nothing is executed.

> 
> I've posted the following code to use as an example.  Any critique of
> the code in addition to my specific question is welcome:)  I
> just don't
> see a reason to stick an "else" statement on the end of that block.
> 
> http://www.nixnotes.org/perl_dump.html

Looks fine to me, except that if the last condition fails, the program will
silently end and the user won't know why. Does that matter?

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to