TT#69200 Reimplement contains() based on List::Util's any()

Change-Id: Ic3d8eb5a6bdcb6b6021706c9450f06b65db4e688
(cherry picked from commit 54704e0837)
mr7.5.5
Guillem Jover 6 years ago committed by Rene Krenn
parent 7aaca71a18
commit bcf28c9d75

@ -3,6 +3,8 @@ use strict;
## no critic
use List::Util qw(any);
use NGCP::BulkProcessor::Table;
require Exporter;
@ -115,28 +117,19 @@ sub reversearray {
}
sub contains {
my ($item, $array_ptr, $case_insensitive) = @_;
my ($item,$array_ptr,$case_insensitive) = @_;
my $result = 0;
if (defined $array_ptr and ref $array_ptr eq 'ARRAY') {
if ($case_insensitive) {
foreach my $element (@$array_ptr) {
if (lc($element) eq lc($item)) {
$result = 1;
last;
}
}
} else {
foreach my $element (@$array_ptr) {
if ($element eq $item) {
$result = 1;
last;
my $result = 0;
if (defined $array_ptr and ref $array_ptr eq 'ARRAY') {
if ($case_insensitive) {
my $lc_item = lc $item;
$result = any { lc eq $lc_item } @{$array_ptr};
} else {
$result = any { $_ eq $item } @{$array_ptr};
}
}
}
}
return $result;
return int $result;
}
sub arrayeq {

Loading…
Cancel
Save