For planetscape ... how to format code to fit an ascii display (eg. Alphabet Blocks Japh):
use strict;
use warnings;
my $code = q[s''useQTk;P($M=newQMainWindow);$M->geometry("0x0");subQJ{
+sprintf"#%02x%02x%02x",randQ256,randQ256,randQ256}subQA{$m->geometry(
+sprintf"%dx%d+%d+%d",$s,$s,$x-$s/2,$y-$s/2)}subQP{$_[0]->overrideredi
+rect(1)}subQH{($G,$H,$I)=($_[0]->geometry=~/(\d+)\+(.+)\+(.+)/);($H+$
+G/2,$I+$G/2)}subQ_{@C=(J,J,J,J)}_;$A=pop;$M->after(50,sub{map{($o,$p)
+=/4|5/?(7*$_-27,1):(2+((ord)-54)/7,1+((ord)-54)%7);$J.="#"x$o.$"x$p}s
+plit//,q[577EUE77ER76KL576RTR77ER76KV87678:76=67887697:877;:76=678876
+97:878@:RR788REV87:8:RR788REP87;7:766=788769F787687:766=78876967UEZ:7
+677G876K77HFM:7677G876K88SKM<78GE96KPYKS<77SR87KV86977<7777847897:869
+77<7777:6997:YES<SS:HEVSEM<SS:HEP;9G<7777:699J;968<7777847896;;K77N77
+77R87K7:;K86N7778E96K86];($s,$d)=($A%2)?(37,-8):(4,3);while($q=substr
+$J,0,80,""){++$r;$j=0;_QifQ$A>1;map{$x=30+12*++$j;$y=12*(11+$r+2*($r>
+10));if(!/Q/){P($m=$M->Toplevel);_Qif$A>3;$m->configure(-highlightt=>
+1,-highlightb=>"black",-bg=>$C[($j<31)+2*($r<11)]);push@A,$m;&A}}spli
+t//,$q;$m->update}while(13!=$s){$s+=$d;@B=@A;while(@B){$_=splice@B,ra
+nd@B,1,();($m,$s,$x,$y)=($_,$s,H($_));&A;$_->update}}sleepQ3;map{$b=s
+plice@A,rand@A,1,();$b->withdraw}@A;exit});MainLoop';];
my $pattern =q[
###
#######
###########
###############
###################
######################
###################### #
###################### ##
################### ###
## ############### ####
##### ########### #####
######## ####### ######
########### ### #######
##### ##### ########
#### ##### ########
### ### #### ########
### ##### ### ########
### ### ### #######
### ## ### ######
### ##### ### ##### ###
# ######### ### #### #######
#### ###### ### ### #### ####
####### ### ### ## #### #####
########### ##### # #### ### ######
############### ## #### #### ######
################### #### ## ### #### #
###################### #### ##### ### ##
###################### # ################### ###
###################### ## ## ############### ####
################### ### ##### ########### #####
## ############### #### ######## ####### ######
##### ########### ##### ### ###### ### #######
######## ####### ###### ### ######### ########
### ###### ### ####### ### ########### ########
### ####### ######## ### #### ### ########
##### ####### ######## ### ## ### ########
###### ##### ######## ### ## ### #######
###### # ### ######## ### #### ### ######
## ## ## ### ####### ### ###### ### #####
## # ####### ###### ######### ### ####
### ####### ##### ###### ### ###
#### ####### #### ### ### ##
########### ### ##### #
######## ## ##
##### #
##
];
# Print the code, formatted to the pattern
foreach my $line (split /\n/, $pattern) {
foreach my $char (split //, $line) {
if ($char eq ' ') {
print " ";
} elsif ($code) {
my $codechar = substr($code, 0, 1, "");
printf "%s", $codechar;
} else {
print "#";
}
}
print "\n";
}
liverpole
|