I have written a sub procedure in perl to check whether if my string array contains a particular value.
sub check_if_entity_exists() {
my $entity = shift;
my @entityarray = @_;
print "my entity to be checked $entity \n";
print "entity array before change @entityarray : \n";
join(" ", map { s/^\s*|\s*$//g; $_ } @entityarray);
print " array after change @entityarray \n";
my $status = "FALSE";
if (grep { $_ eq $entity } @entityarray) {
$status = "TRUE";
return $status;
}
else {
return $status;
}
}
In the above code @entityarray = xyz.com
$entity = xyz.com
Since entity is there in entity array i expect to set to true but flow is going to false
Output log: my entity to be checked xyz.com entity array before change xyz.com : array after change xyz.com
'xyz.com'as per your exmple and it returned"TRUE". So it worked for me.