看板 Perl 關於我們 聯絡資訊
請問一個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
cot123:第一行我想你應該是要打#!/usr/bin/perl吧 04/14 07:42
cot123:另外我想你要的是exists 04/14 07:43
gohiei:我認為是 defined $hash_ref... 04/14 23:20
billmax:問一下問題,為什麼my $hash_ref 跟my %hash_ref 都可以? 04/17 22:54