in reply to in_array and skipping foreach
Any ideas how I can make this better?
Any will do it! Specifically, the any function from the List::Util module:
use List::Util qw( any ); next if any { $_ eq $offer{retailer} } @ignore_merchants;
Many cases of using grep in a conditional can be written using any instead, as it can short-circuit after the first true result.
Of course, a hash is better if you're going to be doing this check a lot of times.
|
|---|