我试图用哈希和子程序准备一个小脚本。老实说,我是 perl 的新手。有人可以告诉我下面的代码有什么问题吗?我得到 Can't use string ("1") as a HASH ref 错误。
#!/usr/bin/perl
use strict;
use warnings;
no warnings 'uninitialized';
use Data::Dumper;
my %match_jobs;
push @{ $match_jobs{'1'}} , {'job_id'=>'13', 'job_title'=>'Article_9', 'job_description'=>'899.00'};
hash_iterate(\%match_jobs);
sub hash_iterate{
my $job_match=@_;
print Dumper($job_match);
foreach my $match_job_row (keys %$job_match) {
my $job_id_ll=$job_match->{$match_job_row}->{'job_id'};
print $job_id_ll;
}
}
输出:- 在 perl-hash.pl 第 17 行使用“strict refs”时,不能使用字符串(“1”)作为 HASH ref。
感谢您的帮助。!