I log all incoming connections to my
opennap server to a postgres database. I get about 625,000 connections per day, and I wanted to sort them by domain so that I could see visually in text where they were coming from. So I'll spare you the database calls. This, however, was a cool little hack to print the hosts out sorted by domain (rather than hostname). You can easily use
File::Slurp to write the scalar obtained.
Credit to risacher for the sprintf right-justify.