Are you sure your strings are text strings when you apply quotemeta?

use Devel::Peek; use Encode '_utf8_off'; my $u = "abc\x{5555}abc"; my $qu = quotemeta $u; # text (UTF-8) Dump $u; Dump $qu; my $s = $u; _utf8_off($s); my $qs = quotemeta $s; # bytes Dump $s; Dump $qs; __END__ SV = PV(0x63d150) at 0x65eb90 REFCNT = 1 FLAGS = (PADBUSY,PADMY,POK,pPOK,UTF8) PV = 0x6550f0 "abc\345\225\225abc"\0 [UTF8 "abc\x{5555}abc"] CUR = 9 LEN = 16 SV = PV(0x63d120) at 0x65eb30 REFCNT = 1 FLAGS = (PADBUSY,PADMY,POK,pPOK,UTF8) PV = 0x662e60 "abc\345\225\225abc"\0 [UTF8 "abc\x{5555}abc"] CUR = 9 LEN = 16 SV = PVMG(0x697c58) at 0x65eb10 REFCNT = 1 FLAGS = (PADBUSY,PADMY,POK,pPOK) IV = 0 NV = 0 PV = 0x6aa700 "abc\345\225\225abc"\0 CUR = 9 LEN = 16 SV = PV(0x63d120) at 0x65eb00 REFCNT = 1 FLAGS = (PADBUSY,PADMY,POK,pPOK) PV = 0x66a030 "abc\\\345\\\225\\\225abc"\0 CUR = 12 LEN = 16

As you can see, no quoting is being done except when the string is treated as bytes.


In reply to Re: postgres reg expression quoting (again) by almut
in thread postgres reg expression quoting (again) by zdzieblo

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.