#!/usr/local/bin/perl -w # # returns a subset of M of the N lines you give it # randsubset.p N=273 M=82 $N = 273 ; $M=82 ; $seed="123"; # new feature 99 07 30 eval "\$$1=\$2" while @ARGV && $ARGV[0]=~ /^(\w+)=(.*)/ && shift; srand($seed) ; while($N && $M && ($_ = <>)) { if ( ($M *1.0/$N) > rand() ) { print ; $M -- ; } $N -- ; }