Guest User

Untitled

a guest
Jun 2nd, 2017
300
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #!perl -pl
  2.  
  3. $" = '^';
  4.  
  5. my %codes = qw(< < > > ^ ^ e e s s ; e^ M >s b <^  <e^  >s^ * <es H es^ \\ <>^ v >es^);
  6.  
  7. my %chars = (
  8.     '<' => 's>^><>',
  9.     '>' => 's<^>^>^',
  10.     '^' => 's>^>^>',
  11.     'e' => 's>^>e>',
  12.     's' => 's>^>s>',
  13.     '0' => 's>^>e<<e>e',
  14.     '1' => 's>^>s^^^>e',
  15.     ';' => 's<^><e^<^>>e',
  16.     'v' => 's<^><<^<^>>^<eee^>^<^^^s>^<^^^e>>ee',
  17. );
  18.  
  19. sub wrap {
  20.     my (@codes, @c);
  21.  
  22.     for (reverse $_[0] =~ /./g) {
  23.         my $c = $codes{$_} or die "Unknown char: $_";
  24.         @c = ($c . '^^' x ((@c + 1 - length $c) / 2)) =~ /./g;
  25.         $codes[$_] =~ s/^/$c[$_]/ for 0..$#c;
  26.         s/([<>])([<>])/$2$1/ for $codes{$_};
  27.     }
  28.  
  29.     @codes = map "<$_>", @codes;
  30.     return "s<><@codes>eeee";
  31. }
  32.  
  33. sub num {
  34.     my $b = unpack "b8", $_[0];
  35.     my @r;
  36.     push @r, '^^^s' . '<<^^^s' x $-[0] while $b =~ /1/g;
  37.  
  38.     local $_ = "@r";
  39.     s/\^\^\^s/>>>s/ or die while y/<// > y/>// + 2;
  40.     s/\^\^\^s/><>>s/ if y/<// == y/>// + 2;
  41.     s/\^\^\^s/><<>>s/ if y/<// > y/>//;
  42.  
  43.     return ~~reverse $_;
  44. }
  45.  
  46. s/\s+/\n/g;
  47. @_ = map {
  48.     $chars{$_} ||= wrap(q(s<\H*>) . num($_) . q(e^s<^>;v;;\e^<sHebMM>));
  49. } reverse /./g;
  50.  
  51. $_ = "@_^s<><<eee<e^<see><>>>^<^<^>^^^^s^s^s>^<^^^^^^^^^^^>^<^^^>>eeee";
RAW Paste Data