in reply to Re^2: RegEx for OpenOffice::OODoc as in $doc->selectElementsByContent()
in thread RegEx for OpenOffice::OODoc as in $doc->selectElementsByContent()

... 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:  <%-{-{-{-<

Replies are listed 'Best First'.
Re^4: RegEx for OpenOffice::OODoc as in $doc->selectElementsByContent()
by EigenFunctions (Beadle) on Jun 08, 2016 at 14:30 UTC
    Thank-you for the explanation, I now understand. I appreciate the effort very much.

    Thanks,
      EigenFunctions
      OpSys: Win7 Professional/Home Premium x64 Service Pack 1