I was looking for a solution in the Q&A section that would remove the elements in @B from @A, returning @C. I happened upon the exact question as mine, however one of the answers supplied (dragonchild's) was the opposite of what was wanted and I think whoever is in charge of this should substitute it with the following:
#!perl! -w
use strict;
use Data::Dumper;
my @A = ( 'yahoo.com', 'altavista.com', 'yahoo.com/index.html' );
my @B = ( 'yahoo.com', 'webcrawler.com' );
# The task: make a @C such that @C = ( 'altavista.com' )
# dragonchild's solution:
my @C = map { my $x = $_; grep { $x =~ /\Q$_/i } @B } @A;
# produces ( 'yahoo.com', 'yahoo.com' )
# proper solution:
my @D = grep {
my $x = $_;
my @matches = grep { $x =~ /\Q$_/i } @B;
! @matches
} @A;
print Dumper [ \@A, \@B, \@C, \@D ];
Thanks otherwise to
dragonchild who has provided many a useful solution to monks like me learning Perl, I'm sure this was just a hasty mental oversight.