Interesting addition:
With the following code:
use strict; use warnings; my $teststring = qq/Hello# World/; my $regex1 = qr{\QHello# World\E}x; my $regex2 = qr{Hello\#\ World}x; my $regex3 = qr{$teststring}x; my $regex4 = qr{\Q$teststring\E}x; print "String is $teststring\n"; print "Regex1 is $regex1\n"; print "Regex2 is $regex2\n"; print "Regex3 is $regex3\n"; print "Regex4 is $regex4\n";
I get the following output (perl 5.12.1):
String is Hello# World Regex1 is (?x-ism:Hello\#\ World\\E) Regex2 is (?x-ism:Hello\#\ World) Regex3 is (?x-ism:Hello# World ) Regex4 is (?x-ism:Hello\#\ World)
For regex3, the newline is inserted by the qr directive, as verified by a hex dump of the file.

UPDATE:
Output from perl 5.8.9:

$ perl8 regex.pl String is Hello# World Regex1 is (?x-ism:Hello\#\ World\\E ) Regex2 is (?x-ism:Hello\#\ World ) Regex3 is (?x-ism:Hello# World ) Regex4 is (?x-ism:Hello\#\ World )
Output from perl 5.10.1:
$ perl10 regex.pl String is Hello# World Regex1 is (?x-ism:Hello\#\ World\\E) Regex2 is (?x-ism:Hello\#\ World) Regex3 is (?x-ism:Hello# World ) Regex4 is (?x-ism:Hello\#\ World)
So, it looks like there may be an edge case that was partially fixed.

UPDATE 2: clarified that initial tests were on 5.12.1
This is perl 5, version 12, subversion 1 (v5.12.1) built for x86_64-linux-thread-multi-ld
This is perl, v5.10.1 (*) built for x86_64-linux-thread-multi-ld
This is perl, v5.8.9 built for x86_64-linux-thread-multi-ld


In reply to Re^2: Weird quoting with /x modifier by proceng
in thread Weird quoting with /x modifier by ykar

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.