Lastly, references can be used to create anonymous data structures which are destroyed once you're done with them. An anonymous array is created by using square brackets instead of round ones. An anonymous hash uses curly brackets instead of round ones.
# the old two-step way: my @array = qw(a b c d); my $array_ref = \@array; # if we get rid of $array_ref, @array will still hang round using up # memory. Here's how we do it without the intermediate step: my $array_ref = ['a', 'b', 'c', 'd']; # look, we can still use qw() too... my $array_ref = [qw(a b c d)]; # more useful yet: my %transport = ( 'cars' => [qw(toyota ford holden porsche)], 'planes' => [qw(boeing harrier)], 'boats' => [qw(clipper skiff dinghy)], );