我正在尋找遍歷這些數據結構(基本上是一個目錄結構),我通過給定的路徑。迭代通過數據數組/散列
的目標是要列出根/基本路徑,然後列出所有的子path
■如果它們存在和存在每個子path
,列出從子路徑file
。
我知道這可能需要循環HoH或AoH。有人能告訴我這樣做的perl技術嗎?謝謝。
基準面:/工作/工程/供稿
$VAR1 = {
'recursive' => 'no',
'version' => '0.20.202.1.1101050227',
'time' => '2011-10-26T00:20:18+0000',
'filter' => '.*',
'path' => '/work/eng/feeds',
'directory' => [
{
'owner' => 'tst_act',
'group' => 'eng',
'permission' => 'drwxrwxr-x',
'path' => '/work/eng/feeds',
'accesstime' => '1970-01-01T00:00:00+0000',
'modified' => '2011-08-27T03:13:53+0000'
},
{
'owner' => 'tst_act',
'group' => 'eng',
'permission' => 'drwxr-xr-x',
'path' => '/work/eng/feeds/customer_care',
'accesstime' => '1970-01-01T00:00:00+0000',
'modified' => '2011-10-25T23:54:17+0000'
}
],
'exclude' => ''
};
下一等級:/工作/工程/供稿/ customer_care
$VAR1 = {
'recursive' => 'no',
'version' => '0.20.202.1.1101050227',
'time' => '2011-10-26T00:21:06+0000',
'filter' => '.*',
'path' => '/work/eng/feeds/customer_care',
'directory' => [
{
'owner' => 'tst_act',
'group' => 'eng',
'permission' => 'drwxr-xr-x',
'path' => '/work/eng/feeds/customer_care',
'accesstime' => '1970-01-01T00:00:00+0000',
'modified' => '2011-10-25T23:54:17+0000'
},
{
'owner' => 'tst_act',
'group' => 'eng',
'permission' => 'drwx------',
'path' => '/work/eng/feeds/customer_care/abc',
'accesstime' => '1970-01-01T00:00:00+0000',
'modified' => '2011-10-25T17:12:56+0000'
},
{
'owner' => 'tst_act',
'group' => 'eng',
'permission' => 'drwx------',
'path' => '/work/eng/feeds/customer_care/def',
'accesstime' => '1970-01-01T00:00:00+0000',
'modified' => '2011-10-25T21:05:50+0000'
},
{
'owner' => 'tst_act',
'group' => 'eng',
'permission' => 'drwx------',
'path' => '/work/eng/feeds/customer_care/test',
'accesstime' => '1970-01-01T00:00:00+0000',
'modified' => '2011-10-25T21:28:14+0000'
}
],
'exclude' => ''
};
還有一個層次:/工作/工程/供稿/ customer_care /測試(這裏是文件存在)
$VAR1 = {
'recursive' => 'no',
'version' => '0.20.202.1.1101050227',
'time' => '2011-10-26T00:30:02+0000',
'filter' => '.*',
'file' => {
'owner' => 'tst_act',
'replication' => '3',
'blocksize' => '134217728',
'permission' => '-rw-------',
'path' => '/work/eng/feeds/customer_care/test/q_data_20111023.dat',
'modified' => '2011-10-26T00:29:46+0000',
'size' => '379085',
'group' => 'eng',
'accesstime' => '2011-10-26T00:29:46+0000'
},
'path' => '/work/eng/feeds/customer_care/test',
'directory' => {
'owner' => 'tst_act',
'group' => 'eng',
'permission' => 'drwx------',
'path' => '/work/eng/feeds/customer_care/test',
'accesstime' => '1970-01-01T00:00:00+0000',
'modified' => '2011-10-26T00:29:46+0000'
},
'exclude' => ''
};
你試過了什麼?你遇到了哪些具體問題?你只需要知道'each','keys'和'values'的名字,或者閱讀'perlreftut'? – derobert
如果我可以捕獲每個鍵和值,那將是一個好的開始。 – jdamae