<?xml version="1.0" encoding="windows-1252"?>
<node id="254808" title="Re: Select data between a START and END pattern" created="2003-05-01 16:51:58" updated="2005-08-12 21:40:50">
<type id="11">
note</type>
<author id="56130">
Thelonius</author>
<data>
<field name="doctext">
Although dragonchild gives a good example of .., here's a more general explanation, along with the difference between .. and ...&lt;p&gt;
First of all, there is use of .. in a list context:&lt;code&gt;
@a = 1 .. 7;
&lt;/code&gt;
Then there's the unrelated use in a scalar context.  It only makes sense in a loop.&lt;code&gt;
while (something) {
  if (EXPRSTART .. EXPREND) {
     doit();
   }
}
&lt;/code&gt;
is equivalent to:&lt;code&gt;
$inmatch = 0;
while (something) {
  if (!$inmatch &amp;&amp; EXPRSTART) {
    $inmatch = 1;
  }
  if ($inmatch) {
    doit();
  }
  if ($inmatch &amp;&amp; EXPREND) {
    $inmatch = 0;
  }
}
&lt;/code&gt;
Okay?  Now for three dots:&lt;code&gt;
while (something) {
  if (EXPRSTART ... EXPREND) {
     doit();
   }
}
&lt;/code&gt;
is equivalent to:&lt;code&gt;
$inmatch = 0;
while (something) {
  $wasinmatch = $inmatch;
  if (!$inmatch &amp;&amp; EXPRSTART) {
    $inmatch = 1;
  }
  if ($inmatch) {
    doit();
  }
  if ($wasinmatch &amp;&amp; EXPREND) {
    $inmatch = 0;
  }
}
&lt;/code&gt;
Subtle difference.  To see it in action, compare:&lt;code&gt;
while (&lt;&gt;) { print if /A/ .. /B/ }
&lt;/code&gt; with &lt;code&gt;
while (&lt;&gt;) { print if /A/ ... /B/ }
&lt;/code&gt; on this input file &lt;code&gt;
Here's some text before
Some text with an A
some lines in the middle 1
some lines in the middle 2
some lines in the middle 3
Some text with a B
some useless lines 1
some useless lines 2
some useless lines 3
A line with both an A and a B
some lines after the line with both 1
some lines after the line with both 2
some lines after the line with both 3
Once again, text with a B
more useless lines 1
more useless lines 2
more useless lines 3
&lt;/code&gt;
</field>
<field name="root_node">
254775</field>
<field name="parent_node">
254775</field>
</data>
</node>
