in reply to can any reply out with a better code than this??
If the string may contain characters special to a regex that you want treated as regular characters to match, do /(\Q$string\E){3}/.
Make the match non-capturing, since you are unlikely to be using the captured result: /(?:\Q$string\E){3}/.
If the "3" is always the same and for some reason it isn't fast enough, try repeating it: /\Q$string$string$string\E/.
Save the regex in a variable and reuse it: my $regex = qr/\Q$string$string$string\E/; ... if ($line =~ $regex) ....
|
|---|