References are most often used to create complex data structures. Since hashes and arrays only accept scalars as elements, references (which are inherently scalars) can be used to create arrays of arrays or hashes, and hashes of arrays or hashes.
my %categories = ( 'fruits' => \@fruits, 'rodents' => \@rodents, 'books' => \@books, ); # to print out "gerbil"... print $categories{'rodents'}->[3]; |