in reply to getting random number 8 times never the same
For instance,#!/usr/bin/env perl my $k = shift @ARGV; srand; while (<>) { $. <= $k and do { push @lines, $_; next; }; ($a=rand($.)) < $k and ($lines[$a] = $_); } print @lines;
$ seq 4 20 | ./rand.pl 8 19 5 6 14 16 9 15 11
|
|---|