in reply to Searching through a file

Four problems. (Aside from not previewing your node. Use <c>...</c> around code in your nodes.)

Replies are listed 'Best First'.
Re^2: Searching through a file
by mr_mischief (Monsignor) on Sep 05, 2007 at 18:33 UTC
    if ($line =~ /\Q$string\E/) { ... }

    This is a good idea. I didn't make the leap to quoting the string when building the regex, but that's probably what the OP wants.