On Aug 22, 5:44 am, [EMAIL PROTECTED] (Chris) wrote: > my @gilligan = qw(red_shirt hat lucky_socks water_bottle); > my @skipper = qw(blue_shirt hat jacket preserver sunscreen); > my @professor = qw(sunscreen water_bottle slide_rule batteries radio); > > my %all = ( > Gilligan => [EMAIL PROTECTED], > Skipper => [EMAIL PROTECTED], > Professor => [EMAIL PROTECTED], > );
Those three things look like sets (unordered) to me not lists (ordered). The natural datatype in Perl to represent a set of strings is a hash with keys but no values. Unfortunately there's no elegant way to initialise such a structure in a single step. Here's one of the least inelegant ways. my %all; @{$all{Gilligan}}{ qw(red_shirt hat lucky_socks water_bottle) }=(); @{$all{Skipper}}{ qw(blue_shirt hat jacket preserver sunscreen) }=(); @{$all{Professor}}{ qw(sunscreen water_bottle slide_rule batteries radio) }=(); > unless (grep $item eq $_, %$all_ref{$crew}) { > print "$crew is missing $item.\n"; > } Using hashes this (which as has been point out elsewhere was wrong anyhow) becomes: unless ( exists $all_ref->{$crew}{$item} ) { print "$crew is missing $item.\n"; } Look ma, no loop. But!... see my next reply -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/