Hello Kenton,

It depends on what you want to do. There is not really a "right way", since
the two series of statements you mention will lead to different results.

(I added numbers to the different parts of your examples, makes them a bit
easier to follow)

> if (expression1) {
>       statement1;
> } elsif (expression2) { 
>       statement2;
> }

This evaluates expression1, and executes statement1 if true. If expression1
was false, it will evaluate expression2, and if that is true, will execute
statement2.

> if (expression1) {
>     statement1;
> } elsif (expression2) { 
>     statement2;
> } else {
>       statement3;
> }

This will do the same as the first example, but if expression2 is false,
then it will enter the else and execute statement3. The main difference is
that you provide something to do for both the true and false cases for BOTH
your conditions, whereas in the first example, if expression2 was false it
simply exited and continued down in the file.

Hope this helps,

J-S


-- 
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