#!/usr/bin/perl use strict; use warnings; my @items = qw/yes no no no yes yes no no/; my $number_of_matches = grep(/yes/,@items); print "$number_of_matches\n";
Prints 3.
Update: Noticed that I left out @items, and I see I am not alone in my confusion about exactly what it was the OP wanted.
In reply to Re: Grep reutrn the occurance of a pattern
by moklevat
in thread Grep reutrn the occurance of a pattern
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |