my $C = shift ; my @others = grep ( !/$C/, @_ );Now consider
$passtoC = 'Vanilla';All items match vanilla and nothing is put into others.
my @list = qw / Vanilla Vanilla_Orange_Sherbert Vanilla_Fudge_Swirl / ;
My solution is:
my @others = grep ( !/^$C$/, @_ );Which produces the desired result. I'm just wondering if there is a more direct way, or if there is any possible weirdness that might result from specifying both ^ and $ in the same regexp.
In reply to Using a Regexp to match a string exactly by brainbuz
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |