這是我的問題:Adressing哈希散列與數組
我有一個文件系統,如數據結構:
%fs = (
"home" => {
"test.file" => {
type => "file",
owner => 1000,
content => "Hello World!",
},
},
"etc" => {
"passwd" => {
type => "file",
owner => 0,
content => "testuser:testusershash",
},
"conf" => {
"test.file" => {
type => "file",
owner => 1000,
content => "Hello World!",
},
},
},
);
現在,得到的/etc/conf/test.file
我需要$fs{"etc"}{"conf"}{"test.file"}{"content"}
內容,但我的輸入是一個數組,看起來像這樣:("etc","conf","test.file")
。
所以,因爲輸入的長度是變化的,我不知道如何訪問哈希的值。有任何想法嗎?
相關:http://stackoverflow.com/questions/8671233/programatic-access-of-a-hash-element http://stackoverflow.com/questions/9789420/how-would-you -create-and-traverse-a-hash-of-depth-n-which-the-val http://stackoverflow.com/questions/10965006/convert-string-abc-to-hash-abc- in-perl – daxim 2012-07-31 12:29:13