On 3 Mar 2007, at 00:39, Thomas Wittek wrote:
I'd like the For::Else behaviour more. Especially as I remember numerous times writing an if clause to check if a list is empty before processing it.

That's crazy. If the list is empty foreach still does the right thing - there's no benefit in guarding a foreach with a conditional.

I don't remember many cases where I wrote something like this:

  my $found;
  foreach my $item (@items) {
    if ($item = 'foobar') {
      $found = 1;
      last;
    }
  }
  unless ($found) {
    ..
  }

I'd say that or a close variation of it was a pretty common idiom.

--
Andy Armstrong, hexten.net

Reply via email to