I wrote this code in 1995. For an update from 2018, including a link to a much better online tool for creating upside-down-looking text, see my Words & Stuff column XXX: uʍop-ǝpısdn.
#!/usr/sbin/perl # umop.pl: Program to turn a string upside-down. # # Version 1.0, copyright 1995 by Jed Hartman. # Last modification: 16 August 1995. # # Based on my earlier umop.c. The perl version is much shorter! # # Permission to use, copy, modify, and distribute this software and its # documentation, in whole or in part, for any purpose and without fee is # hereby granted, provided that: (a) the above copyright notice appear in # all copies; (b) both the copyright notice and this permission notice # appear in supporting documentation; and (c) no fee is charged for further # redistribution of the software. This software is provided "as is" without # express or implied warranty. # # Thanks to Jef Poskanzer for the permission-to-use notice. # # # Notes: # # Reads standard input or a list of files on the command line; writes to # standard output. Any character which cannot be reasonably inverted is # left alone; many uppercase characters are converted to lowercase. # Inversions look better in some typefaces than in others. To change the # inversion mapping, edit the two strings in the line containing the "tr" # command. # # Width-to-justify-in defaults to 78 columns. If you want to specify some # other width, use -w width on the command line. # # If by some chance you don't have access to the getopt.pl command-line- # option-handling library, just comment out everything before the first # "while" line below, except the "$width = 78" line. # # Arguably, umop should re-wrap the inverted text to the specified number of # columns, rather than just attempting to justify each line in that number # of columns. But that's a project for another day. # # If you have comments or suggestions, write to me at logos@kith.org. I'm a # novice perl hacker and would be delighted to receive style comments. # Get command-line option(s): require "getopt.pl"; &Getopt('w'); # Set justification width according to command line: if ($opt_w && $opt_w != 1) { $width = $opt_w; } else { $width = 78; } # For each line of input, replace every character with a character that # looks like it upside-down. Then reverse the order of the characters on # the line. while ($a[$i] = <>) { chop ($a[$i]); $a[$i] =~ tr/A-Za-z,`'()[]>p3j6HIrK7WNOdbJS+nAMXhZeq>paj6y!fklwuodbJs+n^mxhz`,,)(][<>i5Eh29L6v/; $a[$i] = reverse $a[$i]; $i++; } # Reverse the order of the lines, and print them right-justified. @a = reverse @a; foreach (@a) { printf "%${width}s\n",$_; }