perl -mstrict -we "my @arr=(1,2,2);print 'exactly two' if (grep{$_==2}@arr) == 2" exactly two