in reply to Re: Using a variable as pattern in substitution
in thread Using a variable as pattern in substitution
@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.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re (3): Using a variable as pattern in substitution
by VSarkiss (Monsignor) on Jun 05, 2002 at 18:30 UTC |