Here is an example, partly from the docs for
Text::ParseWords, (part of core since perl 5). But, it is not using an array, but the whole body of text.
#!/usr/bin/perl
use strict;
use warnings;
use Text::ParseWords;
my $text; do {local $/; $text = <DATA>};
my @words = quotewords('\s+', 1,$text);
my $i = 0;
foreach (@words) {
if (/^".+"$/s) {
printf "<%s> : COUNT %d\n", $_, scalar split;
}
}
__DATA__
"Yes, yes, how was it now?" he thought, going over his dream.
"Now, how was it? To be sure! Alabin was giving a dinner at
Darmstadt; no, not Darmstadt, but something American. Yes, but
then, Darmstadt was in America. Yes, Alabin was giving a dinner
on glass tables, and the tables sang, _Il mio tesoro_--not _Il mio
tesoro_ though, but something better, and there were some sort of
little decanters on the table, and they were women, too," he
remembered.
The out put is:
C:\Old_Data\perlp>perl t33.pl
<"Yes, yes, how was it now?"> : COUNT 6
<"Now, how was it? To be sure! Alabin was giving a dinner at
Darmstadt; no, not Darmstadt, but something American. Yes, but
then, Darmstadt was in America. Yes, Alabin was giving a dinner
on glass tables, and the tables sang, _Il mio tesoro_--not _Il mio
tesoro_ though, but something better, and there were some sort of
little decanters on the table, and they were women, too,"> : COUNT 66