[問題] 對hash of hash 用exist

看板Perl作者 (剛者必折 驕必敗)時間17年前 (2007/04/14 01:43), 編輯推噓2(202)
留言4則, 3人參與, 最新討論串1/1
請問一個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

04/14 07:42, , 1F
第一行我想你應該是要打#!/usr/bin/perl吧
04/14 07:42, 1F

04/14 07:43, , 2F
另外我想你要的是exists
04/14 07:43, 2F

04/14 23:20, , 3F
我認為是 defined $hash_ref...
04/14 23:20, 3F

04/17 22:54, , 4F
問一下問題,為什麼my $hash_ref 跟my %hash_ref 都可以?
04/17 22:54, 4F
文章代碼(AID): #167y5483 (Perl)