in reply to
Randomize lines with limited memory
You can simply trade time for space here:
- Count the number of lines in your text file
- Generate a randomized order of lines by choosing a permutation of the line numbers (this will take about 32 bytes per line number).
- Rewind your text file.
- Read up to the line that is to become the next line written.
- Copy it into the target file.
- Repeat the three previous steps until the shuffled file is written out.
Of course, this method won't work well if you always choose the same permutation, but you could also do a Fisher-Yates shuffle of the line numbers and then recreate the file from the line numbers as above.
perl -MHTTP::Daemon -MHTTP::Response -MLWP::Simple -e ' ; # The
$d = new HTTP::Daemon and fork and getprint $d->url and exit;#spider
($c = $d->accept())->get_request(); $c->send_response( new #in the
HTTP::Response(200,$_,$_,qq(Just another Perl hacker\n))); ' # web