#!/usr/bin/perl -w # decode_template.pl - Don Yang (uguu.org) # # 07/08/07 use strict; my $space_start = ord('#'); my $space_end = ord('B'); my $char_start = $space_end + 1; my $char_end = ord('['); my $input = join '', <>; foreach my $code (unpack 'C*', $input) { if( $code == ord('!') ) { print "\n"; } elsif( $code >= $char_start && $code <= $char_end ) { print 'X' x ($code - $char_start + 1); } elsif( $code >= $space_start && $code <= $space_end ) { print ' ' x ($code - $space_start + 1); } elsif( $code >= ord('^') && $code <= ord('}') ) { $code = ($code - ord('^')) * 2 + 1; for(my $bit = 0; $bit < 6; $bit++) { print (($code & (1 << $bit)) ? 'X' : ' '); } } }