For every missing provision, push that provision onto an array,
forcing the passenger to consider the item:
sub check_required_items {
my $who = shift;
my $items = shift;
my @required = qw(preserver sunscreen water_bottle jacket);
my @missing = ( );
for my $item (@required) {
unless (grep $item eq $_, @$items) { # not found in list?
print "$who is missing $item.\n";
push @missing, $item;
}
}
if (@missing) {
print "Adding @missing to @$items for $who.\n";
push @$items, @missing;
}
}
Note the addition of the @missing array. If you
find any items missing during the scan, push them into
@missing. If there's anything
there at the end of the scan, add it to the original provision list.