All pastes #419550 Raw Edit

bf.pl

public text v1 · immutable
·published 2007-04-01 12:40 UTC
rendered paste body
#!/bin/perl
# Perl output generated from a Thutu2 file.

$_="=1";
$|=1; # Output is slow enough that observing it in real time is useful
$row="";
$ninequit=0;
while(!$ninequit)
{
$row =~ s/=/=q/g;
$row =~ s/\t/=t/g;
$row =~ s/\n/=x/g; # The newline at the end of the line becomes =x
$row =~ s/\r/=r/g;
$row =~ s/\f/=f/g;
$row =~ s/\a/=a/g;
$row =~ s/\e/=e/g;
$row =~ s/([!-\/:-<>-@[-`{-~])/=$1/g; #`
defined($row) or $row = '=9';
$_ = $row . $_;
while(1) {
s/=1// and next;
s/=9/=!=x/ and next;
s/[^][,.<>+=-]([^!]*?)=!/$1=!/ and next;
s/==/=/ and next;
s/=%// and next;
s/=x/%x/ and next;
s/([^%])x/$1/ and next;
s/^([^x]*)%x([^x]*)%x/$2$1%x/ and next;
while(/=!/ and 1) {do {
  s/=x// and next;
  s/\-\-/\+\+/ and next;
  s/^\?// and next;
  s/\{\{/=\[/ and next;
  s/\}\}/=\]/ and next;
  s/\+\+$/\+\+\|/ and next;
  while(not(/\+\+/ or 0)) {do {
    s/$/\|\+\+/ and next;
  last;}};
/[^|]$/ and next;
  /^=\+/ and /\+\+/ and do {while(1) {
    s/\+\+/\-\-\./ and next;
    s/^=\+/\?/ and next;
  last;}};
/^=\-/ and /\+\+/ and do {while(1) {
    s/\+\+\./\-\-/ and next;
    s/^=\-/\?/ and next;
  last;}};
/^=\>/ and /\+\+/ and do {while(1) {
    s/\|\+\+(\.*?)\|/\|$1\|\-\-/ and next;
    s/^=\>/\?/ and next;
  last;}};
/^=\</ and /\+\+/ and do {while(1) {
    s/\|(\.*?)\|\+\+/\|\-\-$1\|/ and next;
    s/^=\</\?/ and next;
  last;}};
/^=\,/ and /\+\+/ and do {while(1) {
    s/^=\,/\?/ and next;
    s/\+\+\./\+\+/ and next;
    s/\+\+/\-\-/ and next;
    (($temp = getc()) ? ($_ = ord($temp) . "=x" . $_) : ($_ = "=9" . $_));
    while(1) {do {
      s/=x/%%1%%/ and next;
      s/^=9/0%%1%%/ and next;
      while(/%%1%%/ and 1) {do {
        s/^0%%1%%// and next;
        /^([0-9]+)%%(1)%%/ and do {$s=$1+$2;$p=$1*$2;$d=$1-$2;$m=0;$2 and $m=$1%$2;$g=$1>$2;$c=chr($1);$e=$1==$2;$q=0;$2 and $q=$1/$2;$v=int($q);};
        s/^[0-9]+%%1%%(.*?)\-\-/$d%%1%%$1\-\-\./ and next;
      last;}};
    last;}};
  last;}};
/^=\./ and /\+\+/ and do {while(1) {
    s/^=\./\?/ and next;
    /\+\+(\.*?)(\|)/ and do{$c=ord($1);$e=$1eq$2;$g=$1gt$2;$u=uc($1);$l=lc($1);$g=length($1);};
    s/\+\+/%%$g%0%%/ and next;
    /%%([0-9]+)%(0)%%/ and do {$s=$1+$2;$p=$1*$2;$d=$1-$2;$m=0;$2 and $m=$1%$2;$g=$1>$2;$c=chr($1);$e=$1==$2;$q=0;$2 and $q=$1/$2;$v=int($q);};
    s/%%[0-9]+%0%%/%%>$c<%%/ and next;
    /%%>([^a]|[^b])<%%/ and print $1;
    s/%%>([^a]|[^b])<%%/\-\-/ and next;
  last;}};
s/^=!.*$/=9/ and next;
  /\-\-/ and next;
  /\|\+\+\|/ and /^=\[/ and s/^([^]]*)=\[[^][]*?=\]/$1/ and next;
  /\|\+\+\|/ and s/^=\[[^][]*?=\]// and next;
  while(/^=\[/ and 1) {do {
    s/^=\[([^]]*)=\[([^][]*?)=\]/=\[$1\{\{$2\}\}/ and next;
    s/^=\[([^]]*)=\]/$1=\[$1=\]/ and next;
  last;}};
/=\[.*?=!/ and next;
  last;}};
last; }
s/=9// and $ninequit=1;
if(s/(.*?)=x//) # =x marks the end of what to print out.
{
    $orow=$1;
    $orow =~ s/=t/\t/g;
    $orow =~ s/=n/\n/g; # =n converts back to newline.
    $orow =~ s/=r/\r/g;
    $orow =~ s/=f/\f/g;
    $orow =~ s/=a/\a/g;
    $orow =~ s/=e/\e/g;
    $orow =~ s/=([!-\/:-<>-@[-`{-~])/$1/g; #`
    $orow =~ s/=q/=/g;
    # print "\n"; # DEBUG
    print $orow;
}
# Perl changes input source on EOF, but we want to continue in an EOF
# condition after EOF is reached.
$ninequit or ($row eq '=9' and scalar($row = undef, 1)) or $row=<>;
};