in reply to Re^2: No matching
in thread No matching

\Q\E is quotemeta, you must have done it wrong

Replies are listed 'Best First'.
Re^4: No matching
by o_chfa (Acolyte) on Sep 03, 2009 at 09:24 UTC

    The code is as following:

    36 my $prefixSysDescr = quotemeta 'system.sysDescr.0 : DISPLAY + STRING- (ascii): '; ...... 53 for ( $sysDescr ) { 54 /\Q$prefixSysDescr\E/ && do { 55 $sysDescr =~ s/$prefixSysDescr//; 56 print $sysDescr, "\n"; 57 Pause(__LINE__); 58 s/^$prefixSysDescr//g; 59 last; 60 }; 61 /^$prefixSnmpWalk/ && do { 62 Pause(__LINE__); 63 $sysDescr =~ s/^$prefixSysDescr//g; 64 last; 65 }; 66 # $sysDescr = $sysDescr . " " . $sysDescr; 67 } 68 print $sysDescr; 69 Pause(__LINE__); ...

    The script runs straight to line 68. If I omit \Q and \E it matches

      You're double encoding, you use one or the other, not both.
      #!/usr/bin/perl -- use strict; use warnings; my $base = 'system.sysDescr.0 : DISPLAY STRING- (ascii): '; my $one = quotemeta $base; my $two = "\Q$base\E"; print "$_\n" for $base, $one, $two, "\Q$one\E", "\Q$two\E"; __END__ system.sysDescr.0 : DISPLAY STRING- (ascii): system\.sysDescr\.0\ \:\ DISPLAY\ STRING\-\ \(ascii\)\:\ \ system\.sysDescr\.0\ \:\ DISPLAY\ STRING\-\ \(ascii\)\:\ \ system\\\.sysDescr\\\.0\\\ \\\:\\\ DISPLAY\\\ STRING\\\-\\\ \\\(ascii\ +\\)\\\:\\\ \\\ system\\\.sysDescr\\\.0\\\ \\\:\\\ DISPLAY\\\ STRING\\\-\\\ \\\(ascii\ +\\)\\\:\\\ \\\

        GOTCHA: quotemeta '...' ist the same as \Q...\E. Thx