Blob


1 #!/usr/bin/perl
3 # Without running it, can you see what's wrong with this piece of a
4 # program? If you can't see the problem after a minute or two, see whether
5 # trying to run it will give you a hint of how to fix it (you might try
6 # turning on warnings):
8 #my %passenger_1 = {
9 # name => 'Ginger',
10 # age => 22,
11 # occupation => 'Movie Star',
12 # real_age => 35,
13 # hat => undef,
14 #};
15 #
16 #my %passenger_2 = {
17 # name => 'Mary Ann',
18 # age => 19,
19 # hat => 'bonnet',
20 # favorite_food => 'corn',
21 #};
22 #
23 #my @passengers = (\%passenger_1, \%passenger_2);
25 # {} creates hash references rather than actual hashes. Hash references are
26 # stored in scalars not hashes.
28 use v5.24;
29 use warnings;
30 use strict;
31 use utf8;
33 my %passenger_1 = (
34 name => 'Ginger',
35 age => 22,
36 occupation => 'Movie Star',
37 real_age => 35,
38 hat => undef,
39 );
41 my %passenger_2 = (
42 name => 'Mary Ann',
43 age => 19,
44 hat => 'bonnet',
45 favorite_food => 'corn',
46 );
48 my @passengers = (\%passenger_1, \%passenger_2);