我真是老了 一兩個禮拜沒用 又還給駱駝老兄了
只好寫在這裡 以免忘記又再找
Book : Programing Perl (Link here)
9.4. Hashes of Hashes
建立方法: 雙迴圈 use the following two loops:
while ( <> ) {
next unless s/^(.*?):\s*//;
$who = $1;
for $field ( split ) {
($key, $value) = split /=/, $field;
$HoH{$who}{$key} = $value;
}
}
while ( <> ) {
next unless s/^(.*?):\s*//;
$who = $1;
$rec = {};
$HoH{$who} = $rec;
for $field ( split ) {
($key, $value) = split /=/, $field;
$rec->{$key} = $value;
}
}
沒有留言:
張貼留言