Greetings, Encountering some unexpected behavior illustrated in the code snippet below.
In the first foreach loop Seems like when I check for a match between gid306 and the contents of the the ACTIVES array I get an erroneous hit. But as shown in the second foreach loop if I remove gid and just try to match the number 306 it correctly determines there is no match. Is this a bug in Perl or in my understanding? Thanks John Kent #!/usr/bin/perl my($DEBUG) = 1; my(@ACTIVE) = qw {gid240 gid278 gid301}; my(@LOGGED) = qw {gid306 gid240 gid278 gid301}; # This doesn't work, finds a match for every item in # LOGGED, seems to be matching on "gid" but ignoring the number foreach (@LOGGED){ unless (grep /$_/,@ACTIVE){ print "No Match for $__\n" if ($DEBUG == 1); #do something here with what didn't match"; } else { print "found $_ in ACTIVES\n" if ($DEBUG == 1); } } print "\nNew test\n"; # This works!!! foreach (@LOGGED){ my($match) = $_; # Remove the gid from the term to look for $match =~ s/gid//g; unless (grep /$match/,@ACTIVE){ print "No Match for $_\n" if ($DEBUG == 1); # do something here with what didn't match\n"; } else { print "found $_ in ACTIVES\n" if ($DEBUG == 1); } } Results: [EMAIL PROTECTED] cgi-bin]$ ./test_grep.pl found gid306 in ACTIVES found gid240 in ACTIVES found gid278 in ACTIVES found gid301 in ACTIVES New test No Match for gid306 found gid240 in ACTIVES found gid278 in ACTIVES found gid301 in ACTIVES -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>