Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Array of Arrays (AoA)

Instead of naming the internal array references we can use them within the creation of the larger array.

#!/usr/bin/env perl
use strict;
use warnings;

my @names = (
    [ qw(Foo Bar Baz) ],
    [ qw(Moo Zorg) ],
);

print "$names[0]\n";              # ARRAY(0x703dcf2)
print "@{ $names[0] }\n";         # Foo Bar Baz
print "@{ $names[1] }\n";         # Moo Zorg

print "$names[0]->[0]\n";         # Foo
print "$names[0][0]\n";           # Foo