Web lists-archives.com

Re: handling lists in perl




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";
                }
        }
}