Skip to content

Instantly share code, notes, and snippets.

@clausd
Last active December 15, 2015 12:18
Show Gist options
  • Save clausd/5258824 to your computer and use it in GitHub Desktop.
Save clausd/5258824 to your computer and use it in GitHub Desktop.
Selfreproducing perl program
$program = <<'EOP';
$program = <<'EOC';
EXPANDME
EOC
$program = substr($program,0,-1);
$outer = $program;
$outer =~ s/EOC(..)$/EOP$1/m;
$outer =~ s/EOC$/EOP/m;
$outer =~ s/EXPANDME/$program/;
print $outer;
EOP
$program = substr($program,0,-1);
$outer = $program;
$outer =~ s/EOC(..)$/EOP$1/m;
$outer =~ s/EOC$/EOP/m;
$outer =~ s/EXPANDME/$program/;
print $outer;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment