in reply to Word frequency in an array

Hang on, I figured it out.
@fool = grep (/foo/, @array);

Are you sure?
What you have done there is extracted all the elements of @array that contain the string 'foo', and placed them in another array called @fool. If you want to know how many there are, you still need to do something with @fool. Of course, this is as simple as:

my $count_foo = scalar @fool;
But there is no real need for the intermediate array, so you could have just done:
my $count_foo = grep (/foo/, @array);
But wait, are you sure that is what you really want?
Consider the following example array - how many matches would you expect?
my @array = qw(foo bar food foofighters kung-foo);
If the answer is only one, then you need to use something like this:
my $count_foo = grep { $_ eq 'foo' } @array;
Cheers,
Darren :)