http://qs321.pair.com?node_id=1200151


in reply to Re: Set condition only if array becomes empty
in thread Set condition only if array becomes empty

thanos1983
Nice solution, but I feel it would be beautiful if one's function has only one return, instead of two or more.
Using a flag as choroba stated. something like thus:

... sub check { my $seen = 0; for my $el (@{shift(@_)}) { if ($el eq '3'){ # we only need the first occurrence $seen = 1; last; } } return $seen == 1? 'Found': 'Not Found'; # NOTE } ...

If you tell me, I'll forget.
If you show me, I'll remember.
if you involve me, I'll understand.
--- Author unknown to me