For start, we know how can we output random lines from a txt file:
perl -MList::Util -e 'print List::Util::shuffle <>' words.txt
But we need a general solution (perl is usually installed on every unix-like OS) to output 4 random words from a txt file, how can we do it?
$ cat words.txt ... alpha beta gamma delta epsilon ... $
The "..." represents many other words.
Example output (without newline between them, but one unix newline is needed at the end, spaces should separate them):
$ perl SOMEMAGIC words.txt gamma alpha delta beta $
Using only perl, the shortest possible solution (oneliner).
It will be used as human memorable password generator: https://xkcd.com/936/
Since afaik perl is enough good to be named "random generator".
Example common english wordlist with 32768 unique lines: https://pastebin.ubuntu.com/23726760/