如何从Perl中的哈希中删除键?

时间:2013-08-28 05:35:27

标签: perl hash perl-data-structures

如何从现有地图中删除密钥?

if (exists $sampleMap{1})
{
      #Here I want to remove the "1" key from sampleMap
}

1 个答案:

答案 0 :(得分:6)

使用delete删除哈希键:

if (exists $sampleMap{1})
{
      delete $sampleMap{1}; #Here I want remove the "1" key from sampleMap.
}

有关详细信息,请查看delete