my %gilligan_info = (
name => 'Gilligan',
hat => 'White',
shirt => 'Red',
position => 'First Mate',
);
my %skipper_info = (
name => 'Skipper',
hat => 'Black',
shirt => 'Blue',
position => 'Captain',
);
my @crew = (\%gilligan_info, \%skipper_info);
my $ref_to_gilligan_info = {
name => 'Gilligan',
hat => 'White',
shirt => 'Red',
position => 'First Mate',
};
my $ref_to_skipper_info = {
name => 'Skipper',
hat => 'Black',
shirt => 'Blue',
position => 'Captain',
};
my @crew = ($ref_to_gilligan_info, $ref_to_skipper_info);
As before, you can now avoid the temporary variables and insert the
values directly into the top-level list:
my @crew = (
{
name => 'Gilligan',
hat => 'White',
shirt => 'Red',
position => 'First Mate',
},
{
name => 'Skipper',
hat => 'Black',
shirt => 'Blue',
position => 'Captain',
},
);