in reply to Shortcutting grep in boolean context

In scalar context, grep returns the number of times the expression was true. Counting things is an extremely common usage of grep. And in "boolean context" you still have the issue of when grep's code block is used for side effects.
  • Comment on Re: Shortcutting grep in boolean context

Replies are listed 'Best First'.
Re^2: Shortcutting grep in boolean context
by perlancar (Hermit) on Jan 03, 2017 at 21:35 UTC

    OK. Well, for large lists I'll settle with foreach + last + do block then :) And when the lists are not large, just grep.