Here's an algorithm from the Camel Book:
srand; rand($.) < 1 && ($line = $_) while <>;
This has a significant advantage in space over reading the whole file in
srand; rand($.) < 1 && ($line = $_) while <>;
This has a significant advantage in space over reading the whole file in