@array2 = grep {$_ =~ s/\b$stopword\b//g } @array1;
or does grep compare favorably to a foreach as far as efficiency?
Some people fall from grace. I prefer a running start...
UPDATE:
After thinking on this a bit, I think this solution would work for the problem. Fellow monks, please point out my folly if I'm wrong with this.
#!/usr/bin/perl use strict; my @list = qw( red blue orange yellow black brown green ); print join( ' ', @list ); print "\n"; @list = grep { m/e/io } @list; print join( ' ', @list ); print "\n";
I realize my regex isn't what the original poster was trying to do, but the idea is the same I believe.
This is what I was trying to say in response earlier but I seem to have had a brain fart this morning.
In reply to Re: Re: Using a variable as pattern in substitution
by Popcorn Dave
in thread Using a variable as pattern in substitution
by stew
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |