http://www.perlmonks.org?node_id=304257


in reply to Randomize lines with limited memory

Buckets. Buckets buckets buckets.

Open in file,
open (n) out files,
read line by line,
output to out file rand(n)
close all files
append all out files together at end

for better randomness, greater (n) is good, and operation can be repeated as many times as desired. Do it at least twice to avoid order bias.

love the buckets