Here's a small Perl script to turn text upside down.

This works by reversing every line's order, then substituting each character with character that resembles the subsitituted character most when it's turned upside down (for example, I've always thought 'h' looks like '4' when it's upside down.)

The result of this thing depends a lot on the terminal font. Too bad that ASCII has a few characters that look good this way.

This program, as of writing, has some shortcomings:

  • It doesn't translate square brackets (or many other ASCII characters, for that matter), and it does nothing to high bit characters (ISO 8859-1).
  • While text goes upside down, it doesn't mean lines do the same trick. (Not that nice to implement pipewise, unless we push stuff into a stack, reverse it, and then process it line by line - memory consumptive for big files, unless we use temporary files.) It would be fairly easy to implement, though.
  • Yeah, the capital letters were the worst to figure out! Tell the d00dz to spare the capital letters - or they'll be in big trouble when the revolution comes, because if they can't speak in upside down letter's they're the first to be against the wall =)

Code was inspired by a program written by my friend in =)

#!/usr/bin/perl -w
# prints stuff upside down.
# (c) Weyfour WWWWolf 2000-05-18
# Inspired by WolfZone's similiar program =)

use strict;

while(<>) {

  # Punctuation
  #            !""()'',.

  # Numbers (Probably the easiest part)
  #             0123456789

  # Characters
  #         abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ

  print "", (reverse split //), "\n";

Turn your monitor upside down to read this = `s!y+ peaJ o+ umop ap!sdn Jo+!uow Jnoh uJnL

(The latter is actually a perpetuum mobile: You turn the monitor upside down to read that, and right on next to it, you have, upside down, orders to turn the monitor upside down. See how to keep a fool in suspense.)

Log in or register to write something here or to contact authors.