Trying out an exercise that uses dereferencing Below is code and error
#! /usr/bin/perl use v5.16.3; use strict; use warnings; ## 7/31/19 ## program uses derefence to simplify subroutine from previous program sub check_required_items { my ($who, $items) = @_; my %whos_items = map { $_, 1 } @$items; # the rest are the person +'s items my @required = qw(preserver sunscreen water_bottle jacket); for my $item (@required) { unless ( $whos_items{$item} ) { # not found in list print "$who is missing $item, \n"; } } } my @gilligan = qw(red_shirt hat lucky_socks water_bottle); check_required_items('gilligan', @gilligan); my @skipper = qw(blue_shirt hat jacket preserver sunscreen); my @professor = qw(sunscreen water_bottle slide_rule batteries radi +o); check_required_items('skipper', @skipper); check_required_items('professor', @professor); Can't use string ("red_shirt") as an ARRAY ref while "strict refs" in +use at ./Page_42 line 12.
TIA The Catfish
In reply to Using Dereferencing by catfish1116
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |