in reply to Stupid question about strings...

The | character is a metacharacter, and if it exists in $str2, it is being interpreted as alternation. You probably want something like this:

if( $str1 =~ m/\Q$str2/gi ) { ...

Dave

Replies are listed 'Best First'.
Re^2: Stupid question about strings...
by AnomalousMonk (Archbishop) on Jul 14, 2014 at 11:55 UTC
    if( $str1 =~ m/\Q$str2/gi ) { ...

    The use of the  /g modifier is meaningless in this context, although it does no harm.

Re^2: Stupid question about strings...
by kepler (Scribe) on Jul 14, 2014 at 08:45 UTC
    Ok....I was being stupid..... Thank you very much for the help :) Kind regards, Kepler

      Not stupid. It's an easy mistake to make. By the way; I like the index option mentioned later in the thread better if your search string is just a string and not a pattern.


      Dave