haukex has asked for the wisdom of the Perl Monks concerning the following question:
Over on StackExchange I posted an answer to a question that takes an input file and replaces each digit 0-9 with a random lowercase letter a-z - a different set of random letters on each run of the program, but within one run of the program, each digit should always be replaced by the same letter. The following is what I came up with, but I had a feeling this could be golfed, because the whole shuffle invocation adds a lot of characters. (One idea I had was maybe the random order of hash keys could help, but I guess I'm not feeling creative enough.) Any ideas? :-)
perl -MList::Util=shuffle -M5';$x=join"",shuffle a..z' -pe 'eval"tr/0-9/$x/"' input.txt
WebPerl link (requires modern browser)
Update: Thanks everyone for the inspiring responses so far! :-)
|
|---|