Quine (Perl)
From LiteratePrograms
- Other implementations: BASIC | Clojure | dc | Erlang | Forth | JavaScript / URI | Lisp | Oz | Perl | Python | Smalltalk
A "Quine" is a program that prints its own sourcecode when it is run. For a definition, see Wikipedia's article on Quines. I also recommend David Madore's Page for a highly readable introduction.
Quine in Perl, which use heredoc. Main problem is last newline in heredoc.
<<Quine1.pl>>= $quine = <<'END'; $quine = <<'END'; %s %s ($quine2) = $quine =~ /(.*)\n$/s; printf $quine, $quine2, 'END'; END ($quine2) = $quine =~ /(.*)\n$/s; printf $quine, $quine2, 'END';
External links
- Perl Signature Quine
- Perl quine
- More perl quine
Download code |