Want more features on Pastebin? Sign Up, it's FREE!
Guest

phonetic metachars

By: a guest on Apr 16th, 2011  |  syntax: Perl  |  size: 2.69 KB  |  views: 426  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. #!/usr/bin/perl
  2.  
  3. # list borrowed from http://www.codinghorror.com/blog/2008/06/ascii-pronunciation-rules-for-programmers.html
  4. my %chars = (
  5.     '!' => [qw(bang pling excl not shriek factorial exclam smash cuss boing yell wow hey wham eureka spark-spot soldier)],
  6.     '"' => [qw(literal double-glitch dieresis dirk rabbit_ears double_prime)],
  7.     '#' => [qw(hash crunch hex mesh grid pound sharp grid crosshatch octothorpe flash square tictactoe scratchmark thud thump splat pigpen)],
  8.     '$' => [qw(dollar currency buck cash string ding cache big_money)],
  9.     '%' => [qw(percent mod grapes 007)],
  10.     '&' => [qw(amp amper and address reference andpersand bitand background pretzel)],
  11.     "'" => [qw(apostrophe single_quote quote prime glitch tick irk pop spark acute_accent)],
  12.     '(' => [qw(lparen open wax parenthisey left_ear)],
  13.     ')' => [qw(rparen close wane unparenthisey right_ear)],
  14.     '[' => [qw(bracket square uturn)],
  15.     ']' => [qw(unbracket unsquare uturn_back)],
  16.     '{' => [qw(lsquiggley curley leftit embrace)],
  17.     '}' => [qw(rsquiggley uncurley rytit bracelet)],
  18.     '<' => [qw(read suck gozouta from crunch tic)],
  19.     '>' => [qw(write blow gozinta into zap tac)],
  20.     '*' => [qw(asterisk star splat wildcard gear dingle mult spider aster times twinkle glob)],
  21.     '+' => [qw(plus add cross intersection)],
  22.     ',' => [qw(comma cedilla tail)],
  23.     '-' => [qw(dash hyphen minus worm option dak bithorpe)],
  24.     '.' => [qw(period dot point decimal radix fullstop spot)],
  25.     '/' => [qw(slash stroke slant diagonal solidus over slak virgule slat)],
  26.     '\\' => [qw(backslash hack whack escape backslant backwhack bash rvirgule backslat)],
  27.     ':' => [qw(colon dots twospot)],
  28.     ';' => [qw(semicolon semiweenie hybrid pitthwong)],
  29.     '=' => [qw(equals gets takes quadrathorpe halfmesh)],
  30.     '?' => [qw(question query quiz whatmark what wildchar huh hook buttonhook hunchback)],
  31.     '@' => [qw(at strudel each vortex whorl whirlpool cyclone snail ape cat rose cabbage commercial)],
  32.     '^' => [qw(circumflex caret hat control uparrow xor chevron shark sharkfin fang exponent pointer)],
  33.     '_' => [qw(underline underscore underbar skid flatworm)],
  34.     '`' => [qw(grave backquote backprime backspark unapostrophe birk blugle backtick backglitch push quasiquote)],
  35.     '|' => [qw(bar or vbar pipe vertical thru spike)],
  36.     '~' => [qw(tilde squiggle twiddle not approx wiggle swungdash enyay)],
  37. );
  38.  
  39. while (<>) {
  40.     my $english = join('', (map {explain($_)} split('', $_)));
  41.     $english =~ s/ +/ /g;
  42.     $english =~ s/^ //g;
  43.     print $english;
  44. }
  45.  
  46. sub explain {
  47.     my $c = shift;
  48.     if ($ra = $chars{$c}) {
  49.         return " " . $ra->[int(rand(scalar @$ra))] . " ";
  50.     }
  51.     return $c;
  52. }
clone this paste RAW Paste Data