I assume the part you're having trouble with is getting the regular expression into a variable and treating it as a regular expression instead of a string. If you read perldoc perlop in the section on "Quote and quote-like operators", you'll find the subsection "Regex Quote-Like Operators" which will help you.
Basically the trick is this: Once you get the regex into a string, you can use the qr operator to turn it into a reference to a regex that you can use just like a regular expression:
$ cat regex_in_str.pl #!/usr/bin/perl use strict; use warnings; my $r = "ab+c*d"; my $rRegex = qr/$r/; for my $t (qw( abcd aabbbd acccd dbca )) { if ($t =~ $rRegex) { print "MATCH: $t\n"; } } $ perl regex_in_str.pl MATCH: abcd MATCH: aabbbd $
So all you need to do is read the name and representation of your regular expression from a file, convert the representation into a reference to a regex and load your array.
...roboticus
When your only tool is a hammer, all problems look like your thumb.
In reply to Re: Find Replace text with list
by roboticus
in thread Find Replace text with list
by wa2nlinux
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |