I need to execute "else" condition only if , foreach checks all the values of the array and array has become empty. I am using the following code (some commands are internal to the organization, but you can infer)
$rh->cmd('show pim join summary | except "^Instan +ce|^Route"'); my $output = $rh->get_response; my @outputlist = split /\s+/, $output; foreach $output (@outputlist) { if ($output eq "3000") { put_log("All PIM groups are learned in + Master"); } else { put_log ("fail"); } }
output of the above command "show pim join summary | except "^Instance|^Route" is below
regress@sherlock# run show pim join summary | except "^Instance|^Route +" (s,g) 3000 200
In the above code, foreach gets each member of the array and it finds 3000 in the middle and it passes, but i want the else condition to be executed only once , not for each array element comparison. More precisely, else should be excuted only after the array is empty and 3000 is not found. Is there a way to do it
In reply to Set condition only if array becomes empty by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |