in reply to selecting N random lines from a file in one pass

Thanks, you must have read my mind. I was just thinking about this same problem yesterday!

There is one potential problem, depending on what one wants. If the file size is smaller than the sample size, you can get a sample with "holes":

$ ./select.pl 3 1 2 [0] '2' [1] '' [2] '1'