如何从Perl中的哈希中删除键? [英] How to remove keys from hash in Perl?

查看:1139
本文介绍了如何从Perl中的哈希中删除键?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

How do I remove the key from an existing map?

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

推荐答案

使用delete删除哈希键:

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

有关更多详细信息,请查看删除.

For more details, take a look at delete.

这篇关于如何从Perl中的哈希中删除键?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆