my @Book = (); my %MatchFound; foreach (@Book) { $MatchFound{$_}++ if ( /\bPerl\b/i && /\bMonks\b/i && /\bRule\b/i ); }