<?xml version="1.0" encoding="windows-1252"?>
<node id="1005504" title="Re: How to print the lines immediately above and below a matching line?" created="2012-11-25 11:29:17" updated="2012-11-25 11:29:17">
<type id="11">
note</type>
<author id="880879">
space_monk</author>
<data>
<field name="doctext">
TMTOWTDI answer. :-)

&lt;p&gt;Instead of reading the file line by line as suggested in other answers above, you could also read the entire file into a scalar and use a multi line regexp to do it. Look up use of the &lt;b&gt;/m&lt;/b&gt; option on regexp matching.

&lt;p&gt;Any Monk who wishes to extend this thread with a complete answer using this method is more than welcome to do so (I'm a bit short of time)

&lt;!-- Node text goes above. Div tags should contain sig only --&gt;
&lt;div class="pmsig"&gt;&lt;div class="pmsig-880879"&gt;
A Monk aims to give answers to those who have none, and to learn from those who know more.
&lt;/div&gt;&lt;/div&gt;</field>
<field name="root_node">
1005485</field>
<field name="parent_node">
1005485</field>
</data>
</node>
