in reply to Perl: Function to search for a string
Please pay attention to all the advice given to you thus far -- it will help you in future attempts to seek help here.
In the meantime, I suspect this is your problem:
for my $string (@strings) { if ( $logLines =~ /$string/ ) {
If my gut feel be aright, the problem here is that you are feeding it a string where a regular expression is expected.
Consider using quotemetato convert:
for my $string (@strings) { my $regex = quotemeta $string; if ( $logLines =~ /$regex/ ) {
But this is just a guess -- all the other advice on this thread should be followed if this does not solve your problem. As a rule, we can't fix what we can't run.
|
|---|