看板 Perl 關於我們 聯絡資訊
各位先進好 在我爬文後看到了一個有關hashes of arrays的資料型態 在好奇的試了一下後,有個問題一直無法解決 =================================== --codes: %hash=(key => "yes"); print "$hash{key}\n"; --output: yes ================================== 上述程式碼執行結果沒有問題 但當我嘗試以下hashes of arrays的寫法 --codes: %hash=(key =>["yes","no"]); print "$hash{key}\n"; --output: ARRAT (0x819ffd0) =================================== 很明顯他print出記憶體位置 我反覆試了程式結果都無法print出yes no 請問是我在建構資料結構時出錯了? 或是我print的寫法有誤? 謝謝大家指教 -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 120.126.97.64
kornelius:要用 array 的解參照 03/16 18:45
kornelius:$hash{key}->[0] 03/16 18:46
Whynopeople:非常感謝您的指教 03/17 11:19
halu741101:print "@{$hash{key}}"; 03/19 14:57