Neat, but rand might give the same result several times (as has already been pointed out), and you'll loose some lines, although that's unlikely. Here's how I'd do it anyway:
print sort { sprintf("%u",rand(2)) || -1 } <>;
Explanations: rand(2) yields a float between 0 and 2 (2 excluded), sprintf returns the integer part, i.e. 0 or 1. If it's 0, take -1 instead. So the expression in curlies randomly returns 1 or -1, which causes the lines from <> to be randomly exchanged.
My € 0.02
btw, I'd be delight if someone could show me a better/shorter way than sprintf "%u" of getting the integer part of a float.
Update: of course, int (thanks mycocom)! I think I tried it once, but I must've messed up something, and I've been convinced that it didn't work ever since :-(
In reply to Re: randomiseLines
by bwana147
in thread randomiseLines
by fx
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |