Talk:Zombie Speech Translators

From The Urban Dead Wiki
Jump to navigationJump to search

Text to Zombie in Perl

sub t2z($) {
  $_ = shift;
  tr!eiouEIOU!rrrrRRRR!;
  s![^zhrgbmna \.\!\?\-]!!g;
  s! +! !g;
  s!r\b!rh!g;
  s!\b[Aa]\b!hra!g;
  s!([\.\!\?] )(\w)!$1.uc($2)!eg;
  s! +([\.\!\?])!$1!g;
  s!^ *(\w)!uc($1)!e;
  return $_;
}
while(<STDIN>) {
  print t2z($_)."\n";
}

Dunno if this belongs in the main article, but it's here if anyone wants it. PHP is probably more popular, but it should look very much the same. Wish I knew how to do this with /bin/sed --Mozai 17:20, 5 October 2007 (BST)