in reply to Pattern matching and setting the match to a variable

Things like \S in your "pattern" are being interpreted as regular expressions. You should quotemeta before using the string as a pattern. This is also the same as doing /\Q$pattern/ for a pattern.

If you're just matching literal strings, though, index would be a good way to go.

Replies are listed 'Best First'.
Re^2: Pattern matching and setting the match to a variable
by mrbbq (Sexton) on Feb 15, 2008 at 22:20 UTC
    THat worked perfectly!
    {print "$_\n" if /\Q$pattern/;
    Thanks to all who replied.