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
In reply to Re: getting random number 8 times never the same
by bduggan
in thread getting random number 8 times never the same
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |