in reply to grep and $_
The variable $item has each value from the @required list. In scalar context grep will return the number of times that the expression was true. $_ is an aliases to the element in the @skipper list.my @required = qw(preserver sunscreen water_bottle jacket); my @skipper = qw(blue_shirt hat jacket preserver sunscreen); for my $item (@required) { print "$item\n"; unless (grep $item eq $_, @skipper) { # not found in list? print "skipper is missing $item.\n"; } }
|
|---|