Logo

Programming-Idioms

This language bar is your friend. Select your favorite languages!
  • Perl

Idiom #182 Quine program

Output the source of the current program. A quine is a computer program that takes no input and produces a copy of its own source code as its only output.

Reading the source file from disk is cheating.

$_=q(print"\$_=q($_);eval;");eval;

Assigns a string with valid Perl code and then evaluates it. Original author unknown, probably dates back to Usenet days.
int main(){char*s="int main(){char*s=%c%s%c;printf(s,34,s,34);return 0;}";printf(s,34,s,34);return 0;}

New implementation...
< >
a