Dan Anderson wrote:
>
> Does Perl have any kind of else / unless statements, sort of like
> elsif?  I tried:
>
> if ($foo) {
> }
> else unless ($bar) {
> }
>
> but it just gave me syntax errors.  And I guess I could just do:
> if ($foo) {
> }
> else {
>   unless ($bar) {
>   }
> }
>
> But the place in the code I was trying it was for clarity, and all the
> nested unlesses don't seem to add to clarity.

Hi Dan.

No, there's no 'else unless'. It would have to be a single language word
anyway, the obvious choice being 'elsunless' which looks awful.

What you can do is

  unless (<condition>) {
    :
  }
  elsif (<condition>) {
    :
  }
  else {

  }

which may help if you can rewrite your conditions in these terms.

HTH,

Rob



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