#!/usr/bin/perl -w # decode_ending.pl - Don Yang (uguu.org) # # 2014-10-16 use strict; use constant REPEAT_BASE => 93; use constant LITERAL_BASE => 60; my $text = join '', <>; $text =~ s/\n//gs; my $output = ""; for(my $i = 0; $i < length($text);) { my $tag = ord(substr($text, $i, 1)); if( $tag >= REPEAT_BASE ) { my $count = $tag - REPEAT_BASE + 3; $i++; $output .= substr($text, $i, 1) x $count; $i++; } else { my $count = $tag - LITERAL_BASE + 1; $i++; $output .= substr($text, $i, $count); $i += $count; } } $output =~ s/;/\n/g; print $output;