#!usr/bin/perl use warnings; use strict; my @batgoods = map {'bat:-:'.$_}qw(night-visor laser-disruptor zipwire-refill); my %baskets = ( ten => [0..9], bat => [0..8,'bat:-:laser-disruptor'], elf => [0..10], ); my @tenorless = grep { @{$baskets{$_}} <= 10 } keys %baskets; my @hasbat = grep { my $key = $_; grep { my $batitem = $_; grep {$_ =~ $batitem} @{$baskets{$key}}; } @batgoods; } @tenorless; print @hasbat; # bat exit 0;