in reply to Regex ERROR!

have you tried /\Q$comm/ ? I fear it's a problem with the content of $comm.

Replies are listed 'Best First'.
Re: Re: Regex ERROR!
by nofernandes (Beadle) on Jul 15, 2003 at 09:58 UTC
    Thank you Very much!!!
    In did the \Q was the problem!!!

    It might be a stupid question but what does the \Q does in this context??

    Thank you again for your help!!

    Has in my country they said "The one that doesn´t know is like the one that cannot see!!"

      from the perlre man page
          \Q    quote (disable) pattern metacharacters till \E
      
      look at this code:
      $comm = '(xyz'; $line = '123(xyz)456'; if ($line =~ /$comm/) { #error! same as $line =~ /(xyz/ which ha +s an unmatched '(' # do stuff } if ($line =~ /\Q$comm/) { #no error! same as $line =~ /\(xyz/ -- ' +(' is escaped # do stuff }

      --

      flounder

        Hmm..

        Ok.. i get it!! Thank you very much!

        nofernandes
        And I'd like to add that `perldoc perlop' says:
        \Q          quote non-word characters till \E
        
        Which means
        $a = "\Qhello! there? How> what< now%"; die $a; __END__ hello\!\ there\?\ How\>\ what\<\ now\% at - line 2.

        MJD says "you can't just make shit up and expect the computer to know what you mean, retardo!"
        I run a Win32 PPM repository for perl 5.6.x and 5.8.x -- I take requests (README).
        ** The third rule of perl club is a statement of fact: pod is sexy.