a rami | :םש |
---|---|
17:54 20/09/01 | :ךיראת |
How to recomple regular expression ? | :אשונ |
When using a regular expression that contains an interpolated Perl variable,
if it is known that the variable (or variables) will not change during the
execution of the program.
To workaround this problem you can "eval" the regular expression
command so that is will recompile each time.
The problem is this workaround don't work for me !
Here is a small program that demonstrate the problem:
$template="aaaabcdaaa";
for($i=1;$i<=5;$i++){
print $i."\n";
eval {
$template =~ s/abcd/$i/;
};
print "This is template: $template \n---------------------\n";
}
1
This is template: aaa1aaa
---------------------
2
This is template: aaa1aaa
---------------------
3
This is template: aaa1aaa
---------------------
4
This is template: aaa1aaa
---------------------
5
This is template: aaa1aaa