... it's not evident to me why the need for null concatenation ...

I haven't looked at the docs or source at all, but apparently the  selectElementsByContent() method does not like to be passed a reference. The  qr// operator returns a  Regexp reference. In essence, the  "". qr/faith/i expression replicates the approach of choroba above by stringizing this reference before passing it as an argument, but still allowing all the facility of the  qr// operator to form the pattern object in the first place: all the i-s and t-s get properly dotted and crossed, respectively. (You crotted an i in the solution you attempted here.) I feel it's almost always better to use  qr// to build patterns than than to try to express the patterns as strings using string operators that are almost, but not quite, the same.

Here's an example of conversion of a  Regexp object to a string and its subsequent use as a string in a match.

c:\@Work\Perl\monks>perl -wMstrict -le "my $rx = qr{ (?i) f a i t h }xms; print 'qr// object: ', ref_or_not($rx); print $rx; ;; my $rx_stringized = '' . $rx; print 'stringization: ', ref_or_not($rx_stringized); print qq{'$rx_stringized'}; ;; my $s = 'UnFaItHfUl'; $s =~ $rx_stringized; print qq{'$&'}; ;; sub ref_or_not { my $scalar = shift; return ref $scalar ? ref $scalar : 'not a ref'; } " qr// object: Regexp (?^msx: (?i) f a i t h ) stringization: not a ref '(?^msx: (?i) f a i t h )' 'FaItH'
Note that the  =~ operator is quite happy to use a pure string as a match pattern.


Give a man a fish:  <%-{-{-{-<


In reply to Re^3: RegEx for OpenOffice::OODoc as in $doc->selectElementsByContent() by AnomalousMonk
in thread RegEx for OpenOffice::OODoc as in $doc->selectElementsByContent() by EigenFunctions

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.