my(@lines, $line); open(FILE, shift) || die; 1 while ; $line=$.; seek(FILE, 0, $. = 0); rand($line-$.) < $ARGV[0]-@lines && push(@lines,$_) while ; print @lines, "wc -l could have told you this is $. words\n";