Perl - 2次元配列の生成とアクセス
プログラミングPerl Vol.1の同名セクションにあるサンプルコードを写経する。
#配列リファレンスのリストを配列に代入する @AoA = ( [ "fred", "barney" ], [ "george", "jane", "elroy" ], [ "homer", "marge", "bart" ], ); print $AoA[2][1]; # marge #配列リファレンスの配列へのリファレンスを作成する $ref_to_AoA = [ [ "fred", "barney", "pebbles", "bamm bamm", "dino", ], [ "fred", "barney" ], [ "george", "jane", "elroy", "judy", ], ]; print $ref_to_AoA->[2][3]; #elroy
ううむ、配列をハードコーディングするのは大変だ。。