in reply to Perl: Function to search for a string

Are you sure your grep subroutine gets the correct data? Perhaps you can print the data that was passed to the subroutine to make sure.

Please, note that the '.' (dot) that is part of the strings to check for will be considered a regex-wildcard character. To avoid this you can quote-meta this string in the regex: $logLines =~ /\Q$string\E/.

CountZero

A program should be light and agile, its subroutines connected like a string of pearls. The spirit and intent of the program should be retained throughout. There should be neither too little or too much, neither needless loops nor useless variables, neither lack of structure nor overwhelming rigidity." - The Tao of Programming, 4.1 - Geoffrey James

My blog: Imperial Deltronics