On 11/8/05, John W. Krahn <[EMAIL PROTECTED]> wrote: > Tom Allison wrote: > > if ($text =~ /(.*?($crlf))\2(.*)/sm) { > > > > Do I read this right? > > > > the '\2' is a repeat character of the second match > > where match \1 is (.*?$crlf) and > > match \2 is $crlf ? > > Yes, but you don't really need the capturing parentheses there: > > if ( $text =~ /(.*?$crlf)$crlf(.*)/s ) { > > >
That depends; we don't know the contents of $crlf (although we can probably guess). But if $crlf has classes and/or logic, interpolating the variable again will match any of the possiblilities, where the backreference will only match the literal string previously matched. Consider the following: ~/perl> perl -e'$abc="[abc]"; print "matched!\n" if "aa" =~ /($abc)\1/' matched! ~/perl> perl -e'$abc="[abc]"; print "matched!\n" if "ab" =~ /($abc)\1/' but: ~/perl> perl -e'$abc="[abc]"; print "matched!\n" if "ab" =~ /$abc$abc/' matched! -- jay -------------------------------------------------- This email and attachment(s): [ ] blogable; [ x ] ask first; [ ] private and confidential daggerquill [at] gmail [dot] com http://www.tuaw.com http://www.dpguru.com http://www.engatiki.org values of β will give rise to dom!