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

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.