0
這裏的哈希散列是代碼:遍歷數組
#!/usr/bin/perl -w
use strict;
use Data::Dumper;
my $var = {
Cars => {
cars_name => [
"GT500",
"Beetle",
"P1800"
]
},
Bikes => {
Bikes_name => [
"Pulsar",
"Discover",
"CBR"
]
}
};
#Traversing the hash of hash of array
print "$var\n";
foreach my $k1 (keys %{$var}) {
print "$k1\n";
print $var->$k1;
#foreach my $k2 (keys %{$var->$k1}) {
#print"$k2\n";
#}
}
每當我試圖打印cars_name和Bikes_name,我正在一個錯誤信息,說不能調用Unblessed參考方法汽車。我無法弄清楚我在哪裏犯錯誤。那麼,通過我的理解,這個print $var->$k1
;線創建一個概率。所以請任何機構幫助我解決這個問題。
由於