in reply to Re^2: Problem in counting the occurrences of a string in a text file
in thread Problem in counting the occurrences of a string in a text file

I think your problem is, that you only have one counter variable, which is increased for each individual matching.

Consider something like this:

#my $conto = 0; #### REMOVED; not needed my %arrayris; while (my $text = <LISTAPAROLE>){ for my $key (keys %hash){ my $value = $hash{$key}; if ($text =~/$key\/$key\/.*con\/con\/E.*$value\/$value\/S/is){ ### increase for each key/value pair individually $arrayris{ join '-', $key, $value }++; } } } while ( my ($k,$v) = each %arrayris ) { print CONTEGGIO "($k) => $v\n"; }
  • Comment on Re^3: Problem in counting the occurrences of a string in a text file
  • Download Code