1.ARRAYS OF ARRAYS

@AoA = (
[ “fred”, “barney” ],
[ “george”, “jane”, “elroy” ],
[ “homer”, “marge”, “bart” ],
);

$ref_AoA = [
[ “fred”, “barney” ],
[ “george”, “jane”, “elroy” ],
[ “homer”, “marge”, “bart” ],
];

$AoA[1][1] = “george”;
$ref_AoA->[1][1] = “george”;

2.HASHES OF ARRAYS

%HoA = (
carmans  => [ “fred”, “barney” ],
jetsons  => [ “george”, “jane”, “elroy” ],
simpsons => [ “homer”, “marge”, “bart” ],
);

$ref_HoA = {
carmans  => [ “fred”, “barney” ],
jetsons  => [ “george”, “jane”, “elroy” ],
simpsons => [ “homer”, “marge”, “bart” ],
};

$HoA{jetsons}[1] = “george”;
$ref_HoA->{jetsons}[1] = “george”;

3.ARRAYS OF HASHES

@AoH = (
{
Lead => “fred”,
Pal  => “barney”,
},
{
Lead => “george”,
Wife => “jane”,
Son  => “elroy”,
},
{
Lead => “homer”,
Wife => “marge”,
Son  => “bart”,
}
);

$ref_AoH = [
{
Lead => “fred”,
Pal  => “barney”,
},
{
Lead => “george”,
Wife => “jane”,
Son  => “elroy”,
},
{
Lead => “homer”,
Wife => “marge”,
Son  => “bart”,
}
];

$AoH[1]{Lead} = “george”;
$ref_AoH->[1]{Lead} = “george”;

4.HASHES OF HASHES

%HoH = (
carmans  => {
Lead => “fred”,
Pal  => “barney”,
},
jetsons  => {
Lead => “george”,
Wife => “jane”,
Son  => “elroy”,
},
simpsons => {
Lead => “homer”,
Wife => “marge”,
Son  => “bart”,
},
);

$ref_HoH = {
carmans  => {
Lead => “fred”,
Pal  => “barney”,
},
jetsons  => {
Lead => “george”,
Wife => “jane”,
Son  => “elroy”,
},
simpsons => {
Lead => “homer”,
Wife => “marge”,
Son  => “bart”,
},
};

$HoH{jetsons}{Lead} = “george”;
$ref_HoH->{jetsons}{Lead} = “george”;

Related posts 相關文章
2020 年迎來了 PHP 8 與 Perl 7
More...
安裝 perl 5.8.1 版本 – 草記
More...
perl 備註
More...
perl 隨機產生 password 密碼
More...

作者

留言

撰寫回覆或留言

發佈留言必須填寫的電子郵件地址不會公開。