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.

SelfGOL was written to win all four categories in the Obfuscated Perl contest (3rd year, I believe, whose web pages are no longer available) and still comply with other restrictions of not using modules and being under 1000 bytes. Alas, the rules were drastically changed for the following year's contest, and so it was never entered.

the self-replicating code is based on the standard quine in perl

    q[printf pop@s, @s], 
  printf pop @s, @s; 

…expanded into this Obfuscation

#!/usr/bin/perl -s
q<#!/usr/bin/perl -sw
!$s?{do{>.($_=<>).q<}:do{@s=(q[printf+pop@s,@s],q[#!/usr/bin/perl -sw

loosely related,.. from →

Author: Tushar Samant Note: This will produce itself, and will do so no matter what you set $a to in the beginning. So if the length of $a is n, and the size of the allowed character set is C, then at least C**n out of C**(n+K) strings are self-reproducing Perl programs.

$a='X'; print map "\$a='$a'; $_, q($_)", q(print map "\$a='$a';$_, q($_)") 

Author: Brian Raiter


Author: V Vinay


paper on writing quines (in C)

Libarynth > Libarynth Web > ComputerScience > GeneticProgramming > SelfGOL r5 - 30 Sep 2006 - 16:29

  • selfgol.txt
  • Last modified: 2020-10-22 15:13
  • by nik