I'm trying to see if keyword_objects has an element {name=>'CRASH', status=>'+'}.
# $bug is a reference to the below data
{
'keyword_objects' => [
bless( { 'name' => 'CRASH', 'status' => '+'}, 'SomeModule::SomeFilename' ),
bless( { 'name' => 'CUSTOMER', 'status' => '-' }, 'SomeModule::SomeFilename' ) ],
'category' => 'error'
}
I couldn't find something like filter in another language so my alternative was using map.
my @isCrash = map { $_->name eq 'CRASH' && $_->status eq '+' } @{ $bug->{keyword_objects} };
The problem with this is that, when there is no such keyword, every time the operation is done, it seems to return an empty value. @isCrash becomes an array of multiple empty values and if(@isCrash) becomes useless. I surely can introduce a new variable which can be changed from the map operation but I feel like there should be a better way to do it. Someone please chime in and share your knowledge.