On Thu, Apr 03, 2003 at 01:28:55PM -0500, Tony Esposito wrote:

> When you have an if-elsif-else situation like below, where there is no
> action taken on the final 'else', is there a way to just say 'continue' -
> like one would do in C - or is it considered 'ok' to just leave off the
> final 'else'?

Eh?  That's not what "continue" does in C.  Perl's equivalent of C's
"continue" statement is "next".  You seem to be asking about a noop
statement.

You have three options:

  - Just leave off the else
  - Use ;
  - Don't put any statements in the block

These are the same options that you have in C.  Personally, I choose the
first.

> My experience has taught me to include the final 'else' but just add a
> 'continue' command or NULL.  This is to make the code more readable.
> 
> Example:
> 
>     if(! defined($ini_filename)) {
>        return(int 2);
>      }
>     elsif (! -e $ini_filename) {
>        return(int 4);
>     }
>     elsif (-z $ini_filename) {
>        return(int 5);
>     }
>     else {
>  #  do nothing and there's nothing to say so just continue
>     }

What's wrong with this?  It seems fine to me.

-- 
Paul Johnson - [EMAIL PROTECTED]
http://www.pjcj.net

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to