作者split (剛者必折 驕必敗)
看板perl
標題[問題] exist
時間Sat Apr 14 01:43:31 2007
請問一個hash of hash個問題,
我想要用exist測試看看{'c'}存不存在,
但是perl卻會出現
Can't call method "exist" on unblessed reference at test.pl line 5
的錯誤訊息,請問有人知道要怎麼修改嗎?
perl script file如下:
#!/bin/usr/perl
my $hash_ref;
$hash_ref->{'a'}->{'b'}="super";
if (exist $hash_ref->{'a'}->{'c'}){
print $hash_ref->{'a'}->{'c'}."\n";
}
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 140.109.42.2
1F:推 cot123:第一行我想你應該是要打#!/usr/bin/perl吧 04/14 07:42
2F:→ cot123:另外我想你要的是exists 04/14 07:43
3F:→ gohiei:我認為是 defined $hash_ref... 04/14 23:20
4F:推 billmax:問一下問題,為什麼my $hash_ref 跟my %hash_ref 都可以? 04/17 22:54