<?xml version="1.0" encoding="windows-1252"?>
<node id="1016355" title="Re: regex on previous lines" created="2013-01-31 11:36:51" updated="2013-01-31 11:36:51">
<type id="11">
note</type>
<author id="832495">
choroba</author>
<data>
<field name="doctext">
What do you mean by "do a Regex"? Do you want to match the lines agains regular expresisons, or do you want to modify the lines via substitution?&lt;p&gt;
As usually, there are more ways how to do that. For example, if you are in a *nix environment, you can &lt;c&gt;tac&lt;/c&gt; your file and process it from the last line. Or, you can remember the last two lines in case you want to process them:&lt;c&gt;
my @lines;
while (&lt;&gt;) {
    push @lines, $_;
    shift @lines if @lines &gt; 3;
}
if ($lines[2] =~ $regex1) {
    if ($lines[1] =~ $regex2) {
        if ($lines[0] =~ $regex3) {
            # Do your work here.
        }
    }
}
&lt;/c&gt;
&lt;!-- Node text goes above. Div tags should contain sig only --&gt;
&lt;div class="pmsig"&gt;&lt;div class="pmsig-832495"&gt;

&amp;#1604;&amp;#1405;&amp;#4285;† &amp;#6514;&amp;#6482;&amp;#9898;&amp;#10186;&amp;#4281;&amp;#5651;&amp;#5511; &amp;#5045;&amp;#5651;&amp;#5511;&amp;#9137; &amp;#4281;&amp;#6514;&amp;#119243;&amp;#409;&amp;#5651;&amp;#5511;
&lt;/div&gt;&lt;/div&gt;</field>
<field name="root_node">
1016346</field>
<field name="parent_node">
1016346</field>
</data>
</node>
