foreach $key (keys %readers) { if ($key =~ /\b(\w+)\b/) { $name = $1; } else { next; } if ($name eq 'Mozilla') { # do your platform check } elsif ($name eq 'whatever') { # increment the other hash } # and so forth... }