<?xml version="1.0" encoding="windows-1252"?>
<node id="1007560" title="Reading files n lines a time" created="2012-12-06 08:05:59" updated="2012-12-06 08:05:59">
<type id="115">
perlquestion</type>
<author id="823119">
naturalsciences</author>
<data>
<field name="doctext">
 &lt;p&gt;Hi,&lt;/p&gt; 
 &lt;p&gt;I am working on multi GB text files. For now Perl has been good for working them line by line. Using the&lt;/p&gt; 

&lt;code&gt;while($line=&lt;&gt;){do_stuff_with_it_and_print_to_new_file}&lt;/code&gt;

 &lt;p&gt;Now I am in a need to read in files four lines at a time (as I need to do some comparisions in those quartets, but you can imagine that reading files in n lines at time would be helpful in several applications, etc. flat file with name\naddress\nbilling\nname\naddress\nbilling etc. for triplets.)&lt;/p&gt;
 &lt;p&gt;I was able to fulfill my desires for duplets easily with&lt;/p&gt;&lt;code&gt; while($line=&lt;&gt;){$nextline=&lt;&gt;;do_stuff_to_those_poor_two_lines}&lt;/code&gt;, but an application of
&lt;code&gt;while($line=&lt;&gt;){$nextline=&lt;&gt;;$thirdline=&lt;&gt;}&lt;/code&gt; wont work anymore.
 &lt;p&gt;So how could I get on to reading and manipulationg my text files by any number of lines at a time I wish?&lt;/p&gt;

edit: I myself am thinking of somekind of while loop based thingy with possibly seek to keep those loops moving on in the filehandle. etc.

</field>
</data>
</node>
