in reply to Check multiple array elements for a single condition
or if you just want 2 casual elements to be equal to 2 you can chek the lenght of the list returned by grepperl -mstrict -we "my @arr=(1,2,2);print 'both' if [2,2] ~~ @arr[1,2]" both
perl -mstrict -we "my @arr=(1,2,2);print 'exactly two' if (grep{$_==2} +@arr) == 2" exactly two
L*
|
|---|