<?xml version="1.0" encoding="windows-1252"?>
<node id="304043" title="Re: Re: Re: Randomize lines with limited memory" created="2003-11-03 03:01:37" updated="2005-06-15 03:12:39">
<type id="11">
note</type>
<author id="5348">
Corion</author>
<data>
<field name="doctext">
&lt;p&gt;I did mention that I trade space (memory) for time, didn't I?&lt;/p&gt;
&lt;p&gt;Also, my method dosen't involve random seeks, it only involves rewinding the file to the start point, which is a seek to a fixed position in the file. I think you could halve the number of times the file by checking whether the next line number is greater than the current line number and then winding forward to that one, as I think that there is a 50% chance that the next line number to be written is higher than the current number.&lt;/p&gt;
&lt;p&gt;That point is moot though, as [cpan://Tie::File] implements a caching scheme and is a much cleaner solution than my naive but memory conserving approach.&lt;/p&gt;
&lt;div class="pmsig"&gt;&lt;div class="pmsig-5348"&gt;
&lt;small&gt;&lt;code&gt;
perl -MHTTP::Daemon -MHTTP::Response -MLWP::Simple -e ' ;    # The  
$d = new HTTP::Daemon and fork and getprint $d-&gt;url and exit;#spider
($c = $d-&gt;accept())-&gt;get_request(); $c-&gt;send_response( new   #in the
HTTP::Response(200,$_,$_,qq(Just another Perl hacker\n))); ' #  web 
&lt;/code&gt;&lt;/small&gt;

&lt;/div&gt;&lt;/div&gt;</field>
<field name="root_node">
303841</field>
<field name="parent_node">
303989</field>
</data>
</node>
