小编dat*_*rat的帖子

使用数组来处理哈希散列

这是我的问题:

我有一个像数据结构的文件系统:

%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!",
            },
        },
    },
);
Run Code Online (Sandbox Code Playgroud)

现在,为了得到/etc/conf/test.file我需要的内容$fs{"etc"}{"conf"}{"test.file"}{"content"},但我的输入是一个数组,看起来像这样:("etc","conf","test.file").

因此,因为输入的长度是变化的,所以我不知道如何访问散列的值.有任何想法吗?

perl perl-data-structures

2
推荐指数
1
解决办法
100
查看次数

标签 统计

perl ×1

perl-data-structures ×1