Hello Anonymous Monk,
Why don't you try to create a subroutine and apply return into two points. Sample test code below:
use strict; use warnings; use Data::Dumper; use feature 'say'; my @array = qw( 1 2 3 ); my @secondary = qw ( 4 ); sub check { my ($arrayref) = @_; foreach my $element (@$arrayref){ say $element; return 'Found' if ($element eq 3); } return 'Not Found' } say check( \@array ); say check( \@secondary ); __END__ 1 2 3 Found 4 Not Found
Hope this helps, BR.
In reply to Re: Set condition only if array becomes empty
by thanos1983
in thread Set condition only if array becomes empty
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |