For the last class, we had a mini-obfuscated perl contest. The first question asked what the following code (by Matthew Byng-Maddick) outputs:
#!/usr/bin/perl
while(1){last
if++$a==5;s:^\n?(.*)$:$1.q; ;
x(10-++$b).q;*;x(2*$b-1).q;
;:es;print if$a-1} s:.*:q; ;
x9 .q;#;.q;
;.q; ;x8 .q;%;x3 .q;
;:es;print
My simplification of that code follows:
#!/usr/bin/perl
while(1){
last if ++$a==5;
s/^\n?(.*)$/$1.' ' x(10-++$b).'*'x(2*$b-1)."\n"/es;
print if$a-1
}
s/.*/' 'x9.'#'.'\n'.' 'x8.'%'x3."\n"/es;
print
And the output of it is:
*
***
*
***
*****
*
***
*****
*******
#
%%%