Yes, it is a subroutine. I need this script to scan all files for scams or other abuses. I'm using File::Find to search all files under a directory tree then call the subroutine for each file. Patterns are outside the sub.
Based on your suggestion, I will precompile this way:
...
my $list_regex = join '|', @patterns;
my $regex_string = qr/$list_regex/is;
...
if (/($regex_string)/) {print "\n$arg1\n$1\n";}
As for
study, I noticed a little slowness. Maybe it's not efficient in my case.
I still have a big problem.
Graff helped me with file slurp and scanner working few times faster than my original script, but I don't have experience with $/ or $_ and, if you check my last example, global $1 contains entire text between first pattern and second pattern:
pattern1
some text
pattern2
instead of this match:
pattern1.*pattern2
Can you please give me some advice? Thank you!