in reply to regex problem
Well, there are two differences between your examples -- the use of variables and the switch from !~ to =~. Is the latter a typo? If not, then you can accomplish the same thing by using [^$pattern]. In any case, your real question is whether regexes can be constructed, and the answer is yes. It's simply a matter of writing it as a normal string, and using perlfunc:eval to compile at runtime. (Note, you may have to do some character escaping (using '\') in your original string if it gets at all complicated.) For example: my $string = "$foo|$bar"; for ( list ) { eval !~ /$string/; }
As far as expense goes, I can't see any reason why this would be particularly taxing.
Update Juerd++ for the correction regarding [^$pattern]. My mistake.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: regex problem
by Juerd (Abbot) on Feb 09, 2002 at 21:49 UTC |