Well, your whole code can be limited to:
foreach $line (@lines){
$strings{$1}++ if $line =~ m|my regex|;
}
If the value is not there, ++ operator will assume it to be 0 (and then increment to 1). If it is already there - it will simply be incremented.