in reply to Re: Word frequency in an array
in thread Word frequency in an array
Prints "4" - which may or may not be what the OP was after (I suspect not).my @array = qw(foo bar food foofighters kung-foo); my $count_foo = grep (/foo/, @array); print "$count_foo\n";
..might be more what the OP was looking for.my $count_foo = grep { $_ eq 'foo' } @array;
Cheers,
Darren :)
|
|---|