给出以下代码
- #!/usr/bin/perl
- use Data::Dumper;
- my %hash;
- my @colos = qw(ac4 ch1 ir2 ird kr3);
- foreach my $colo (@colos) {
- if(exists $hash{output}{$colo}) {
- print "$colo is in the hash\n";
- }
- }
- print Dumper(\%hash);
我有一个空哈希创建.我有一个包含一些缩写的数组.如果我遍历数组以查看这些人是否在哈希中,则没有任何内容显示给STDOUT,这是预期的但是由于某种原因创建了$hash {output}.这根本不符合逻辑.我所做的只是存在.我哪里做错了?