in reply to Checking for array entry in another array

Apologies.

Obviously the code should read  print STDERR "DEBUG YYY \n" unless map {grep /$_/, @ingfile} @sybfile;

Replies are listed 'Best First'.
Re: Re: Checking for array entry in another array
by bwana147 (Pilgrim) on Jul 26, 2001 at 19:50 UTC

    It won't work because map and grep both localise $_: inside the braces, $_ is aliased to each element of @sybfile in turn. But, grep also aliases $_ to each element of @ingfile, which hides the former $_.

    In fact, you end up doing $_ =~ /$_/, which is pretty much always true. You have to save the map's $_ into some temporary variable:

    print STDERR "DEBUG YYY\n" unless map { my $tmp = $_; grep /\Q$tmp\E/, @ingfile; } @sybfile;

    HTH

    --bwana147