Skip to content

Instantly share code, notes, and snippets.

Created July 9, 2012 13:36
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
Damien Conway's Selfgol
#!/usr/local/bin/perl -sw
if($j){{$^W=$|;*_=sub{$=+s=#([A-z])(.*)#=#$+$1#=g}} #_The_Perl_Journal_#
q<#!/usr/local/bin/perl -sw
if(!$s){>.($_=<>).q<}else{@s=(q[printf+pop@s,@s],q[#!/usr/local/bin/perl -sw
Copy link

yozlet commented Oct 19, 2020

About SelfGOL

SelfGOL was Damian Conway's intended entry to the Obfuscated Perl Contest. It can print its own source code (self-replicate), rewrite other Perl programs so they can print their own source code (and still perform their original functions), detect un-rewritable Perl programs, play John Conway's Game of Life using its own source code or a specified file as a pattern for the board with a board of arbitrary size, or animate a rotating banner of an arbitrary short amount of text. SelfGOL's source is under 1000 bytes of standard Perl, does not import any modules, and doesn't use a single if, unless, while, until, for, foreach, goto, next, last, redo, map, or grep.


selfgol -s outputs its own source code.

selfgol < makes self-replicating (with a command line switch of -s), outputs new source to STDOUT.

selfgol -g [-y=## -x=##] [< gamefile] plays the Game of Life with its own source code or an arbitrary file, with optional height and width restrictions.

selfgol -d[=bannertext] displays a rotating banner with the provided text. If no text is provided, it uses the program name as the text.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment