Thursday, May 8, 2008

Hello World and 99 Bottles of Beer collections

Browsing around for some good C++ sample code I stumbled upon the The Hello World Collection. While that is good, the 99 Bottles of Beer song collection is stunning, informative and fun:

... the collection of the Song 99 Bottles of Beer programmed in different
programming languages. Actually the song is represented in 1200 different
programming languages and variations. For more detailed information refer to
historic information.
I went to look for the Perl example for the song, and was completely baffled!! Everything written inside regular expressions, using a perl module which creates shapes out of perl code! Andrew Savige has some serious coding skills!!

Checking the reg exp, it is a bit (but not much really) readable:

perl -MO=Deparse 99-bottles.pl
'' =~ /(?{eval"\$==pop99;--\$=;sub\n_\{(\$;=(\$=No).\" bottle\".\"s\"x!!--\$=.\" of beer\").\" on the wall\"\}print+
_,\", \$;!\nTake one down, pass it around,\n\",_,\"!\n\n\"while++\$="})/;
$: = 'P';
$~ = 'h';
$^ = 'r';
$/ = '`';
99-bottles.pl syntax OK

No comments: