[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: handling lists in perl



On 2018-12-19 00:43, deloptes wrote:
deloptes wrote:

if ( @array =~ /$hash[$key]/) {
print "key $key with value " . $hash{$key} .
" is in the array of values\n";
}

I checked and it seems the right answer is

my %hash = ( 1=>8,2=>20,6=>100,15=>100 );
my @array = (1, 21, 100, 8, 15, 22, 6, 12, 56);

foreach my $key (keys %hash) {
        for (  @array ) {
                if ($_ eq $hash{$key} ) {
                        print "key $key with value " . $hash{$key} .
                                " is in the array of values\n";
                }
        }
}


much appreciated, cheers.

mick

--
Key ID    4BFEBB31


Reply to: