Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

World's worst Perl quine

by tye (Sage)
on Oct 17, 2001 at 23:39 UTC ( [id://119526]=obfuscated: print w/replies, xml ) Need Help??

syntax error at =# line 2, at EOF Execution of =# aborted due to compilation errors.

Save to a file named "=#". I vaguely recall a similar Perl quine but I was surprised at how long this took me to come up with. I even tested it on several versions of Perl on both Unix and Windows. (:

To validate that it is a quine under Unix (or WinNT and later, if you have a "diff" that knows how to read from stdin), use: perl "=#" 2>&1 | diff "=#" -

Update: In PerlMonk's tradition, I've done the search after creating the node and found that similar quine here. (:

        - tye (no, I don't want to stand too close to that)

Replies are listed 'Best First'.
Re: World's worst Perl quine
by blakem (Monsignor) on Oct 17, 2001 at 23:44 UTC
    Reminds me of one which I believe came from Dominus:
    Illegal division by zero at /tmp/abc line 1.
    Save in file '/tmp/abc' and run using 'perl /tmp/abc' ;-)

    Update: Dominus' original code

    -Blake

Re: World's worst Perl quine
by Sweeper (Pilgrim) on Oct 18, 2001 at 09:47 UTC
    I think Douglas Hofstadter has said something about that in Metamagical Themas (not about Perl, but any programming language you would choose). This was, of course, in the chapter about self-references.
World's most boring Perl quine
by cLive ;-) (Prior) on Oct 18, 2001 at 22:31 UTC
    save as "self".
    open(SELF,'self'); print while(<SELF>);
    cLive ;-)

      I agree that depending on the name of the file is a cheat, so here's how another way to do it. (TIMTOWTC?) It's the same thing, but doesn't depend on the file name.

      seek DATA, 0, 0; print while <DATA>; __DATA__

      I know writing quines isn't a serious subject (at least not to me), but is it fair practice to count on the name of the file to make the quine work? It seems like using metadata like that should be considered a cheat.

      Scott

        No, not at all. Save the following script: print $0 to a file named 'print $0'.

        BTW, that's part of why "worst" is in the title.
                - tye (Sarcasm? What sarcasm?)
      i had thought that quines had to print their code out without reading themselves in?

      strfry()

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: obfuscated [id://119526]
Approved by root
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others meditating upon the Monastery: (7)
As of 2024-04-24 11:31 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found