A colleague at work gave me another challenge recently, or at least they showed me something that Perl can do, which as usual caused me to seek out a more elegant or efficient implementation in another language. A previous challenge had been to write a speedy script that found common rows between two text files, and I had resorted to Python for my implementation, just to make it difficult for myself. After a few rounds of optimisation we found that, when run once, the Perl version was faster, but when run 10 times in a row the Python version took the lead. In this case, though, the challenge was to write a one-liner which would take a string as input and reverse the letters in it. As I enjoy replacing my colleague’s unreadable Perl syntax with a handful of greps, seds, awks, trs and sorts piped into each other, I thought I would aim for a pure BASH solution to this problem. I would include the Perl code for comparison here, but I’m sure the Perl supporters have put it on posters or something to advertise what presumably they believe to be an advantage of Perl over BASH (but they will run out of things to put on those posters once someone gets round to writing mod_bash…).
Continue reading "Backwards Unicode and Shell Support"