It works for me, this is what I used:
@sentences = ("one sentence","two sentences, but not realy","a tesing
+test.");
foreach $sentence(@sentences) {
#print FILE "$sentence\n";
@words = split(/[^\w'a-zA-Z0-9_'-?]/,$sentence);
$Counter =0;
foreach $word(@words){
$Counter = $Counter+1;
print ("$word\n");
}
$sentence_count{($Counter)} = $sentence_count{($Counter)}+1;
}
while (($sentence_count,$word_count) = each(%sentence_count)) {
print ("There are $word_count sentences of $sentence_count words\n
+");
}
Maybe you aren't getting the right thing in @sentences?