我有一个带有各种关键字的哈希。现在,我想在字符串中找到这些关键字的计数。
我刚刚用 foreach 循环编写了部分代码。
use strict;
use warnings;
my $string = "The invitro experiments are conducted on human liver microsom. "
. " These liver microsom can be cultured in rats.";
my %hash = (
"human" => 1,
"liver" => 1,
"microsom" => 1,
);
for my $nme (keys %hash){
# Some code which I am not sure
}
预期输出:human:1; liver:2; microsom:3
有人可以帮助我吗?
谢谢