in reply to Picking Random Lines from a File
When $. == 1,
while ($count<=$size){ rand($.)<1 && ($line=$_); print OUT $line; $count++; }
is the same as
while ($count<=$size){ $line=$_; print OUT $line; $count++; }
because rand(1) always returns something less than 1. Therefore, you always print the first line $size times.
And when it comes time for $. == 2, $count is greater than $size from the first pass, so the loop is never entered.
There's nothing you want to happen to a line more than once, so there shouldn't be any nested loops. The inner while is probably suppose to be an if.
|
|---|