--- Michael G Schwern <[EMAIL PROTECTED]> wrote:

> > 5.005 introduced qr//
> > 
> > $ ~/Reference/5.005_04/bin/perl5.00504-32 -le '$r = qr/(p...)/; $^X
> =~ $r; print $1'
> > perl
> 
> If you're using it for any serious amount of nesting (ie. building up
> a regex
> with a bunch of qr's) it didn't really stabilize until 5.6.  I recall
> this
> from Email::Find and URI::Find.  But for normal use its ok in 5.5.

FYI:  Deeply nesting qr// constructs can have performance impacts.

  ovid $ perl -le '$x=qr{x};$y = qr{y$x};print qr{$y};'
  (?-xism:y(?-xism:x))

Perl will decompile the individual regexes back to strings and later
recompile them.  This recompilation can produce less efficient regexes
than what you wrote.  A better solution, if this turns out to impact
one's code, is to use the q{} and qq{} operators and nest them, though
when you use qq{} you'll have to remember to properly escape things. 
Also, you'll want (?:) constructs in your code.

  bin $ perl -le '$x=q{(?:x)};$y = q{(?:y$x)};print qr{$y};'
  (?-xism:(?:y$x))

See Perl Best Practices "Constructing Regexes" (page 261) for more
information.

Cheers,
Ovid

-- 
If this message is a response to a question on a mailing list, please send
follow up questions to the list.

Web Programming with Perl -- http://users.easystreet.com/ovid/cgi_course/

Reply via email to