in reply to Counting occurence of a list of word in a file

You have this structure in your code:
while my $text=<$testo>){ ... $count += () = /\b$key\b/ig while <>; }

The <> file handle is exhausted in the first run of the outer while loop, thus certainly not doing what you want. Why do you read from <> at all? Doesn't $text already contain an input line?

Replies are listed 'Best First'.
Re^2: Counting occurence of a list of word in a file
by b_vulnerability (Novice) on Nov 11, 2008 at 16:49 UTC
    You are right. I'll correct it and see how it turns out.
    Thanks!
Re^2: Counting occurence of a list of word in a file
by b_vulnerability (Novice) on Nov 11, 2008 at 16:53 UTC
    If I correct that I get this intresting output:
    Use of uninitialized value in pattern match (m//) at prova.pl line 24, + <$testo> line 1.

    I really don't understand.
      What does your "corrected" code look like?