On 4/13/10 Tue  Apr 13, 2010  4:35 PM, "Mimi Cafe" <mimic...@googlemail.com>
scribbled:

> I think this will work, but is it elegant.?

Yes, it will work, and yes, it is elegant, as long as it encapsulates the
logic that is required by your program.

Be sure and watch your indenting, so you can mentally group the correct
branches together (you are a little off in your first 'else'). Also be sure
and put some comments for each conditional that explains what is happening
if it is not obvious (but don't just repeat what is in the condition).

Make sure the 'do this', 'do that', and 'do something else' are not too
long. If they are more than a few statements, use subroutines (with good
names).

> If (condition){
> 
>    if (nexted_condition){
> 
>       do this.
> 
>    }
> 
>    Elsif (nexted_condition){
> 
>       Do that... 
> 
>    }
> 
>   else{
> 
>     Do something else.
> 
>   }
> 
>  
> 
> }
> 
> else{
> 
>    Do something else..
> 
> } 



-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to