Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Quine generator

by Anonymous Monk
on Jul 16, 2007 at 06:34 UTC ( [id://626787]=obfuscated: print w/replies, xml ) Need Help??

Not exactly on obfuscation, but I didn't know where else to put it... Warning: neither __END__ nor @data can be used anywhere in the programs in question, lest it will fail.
#!/usr/bin/perl use strict; use warnings; die("File does not exist.\n") unless -e $ARGV[0]; open(QUINE, "+<", shift); my @quine = <QUINE>; push @quine, 'my @data = <DATA>;'."\n", 'print @data, @data'."\n", "__END__\n"; push @quine, @quine; seek(QUINE, 0, 0); print QUINE @quine; close(QUINE); my @data = <DATA>; print @data, @data __END__ #!/usr/bin/perl use strict; use warnings; die("File does not exist.\n") unless -e $ARGV[0]; open(QUINE, "+<", shift); my @quine = <QUINE>; push @quine, 'my @data = <DATA>;'."\n", 'print @data, @data'."\n", "__END__\n"; push @quine, @quine; seek(QUINE, 0, 0); print QUINE @quine; close(QUINE); my @data = <DATA>; print @data, @data __END__

Replies are listed 'Best First'.
Re: Quine generator
by shmem (Chancellor) on Jul 16, 2007 at 12:08 UTC
    This one from Dave Mitchell is particularly nice: Punctuation free quine
    s zzs vvxv and s ZVZchr 122Zie and s ZVZchr 122Zie and s ZVZchr 122Zie and s SxSlcfirstSe and s YZZxZYvvxvYi and print z and s ZVZchr 122Zie and s ZVZchr 122Zie and s ZVZchr 122Zie and s SxSlcfirstSe and s YZZxZYvvxvYi and print

    --shmem

    _($_=" "x(1<<5)."?\n".q·/)Oo.  G°\        /
                                  /\_¯/(q    /
    ----------------------------  \__(m.====·.(_("always off the crowd"))."·
    ");sub _{s./.($e="'Itrs `mnsgdq Gdbj O`qkdq")=~y/"-y/#-z/;$e.e && print}
Re: Quine generator
by mtve (Deacon) on Jul 16, 2007 at 08:14 UTC

    classical one was:

    open 0;print<0>

      Classical ones are on the Quine page (which is apparently not maintained anymore).

      The shortest non-empty non-cheating one I know is (ends with two newlines)

      print<< x2,v10 print<< x2,v10

      Another that uses perl's various quoting operators to avoid having to escape stuff dynamically is (no newline)

      $a=q(;print"\$a=q($a)$a");print"\$a=q($a)$a"

      Update: see Short quines.

      That's CHEATING!!!!
Re: Quine generator
by Zaxo (Archbishop) on Jul 17, 2007 at 03:17 UTC

    I once twisted the rules to produce a quine generator which would work on programs that print to STDOUT. The twist was that the "own source print" happened on STDERR. That was at Quine code with quinify. It came out of an attempt to quine some of Erudil's famous obfus.

    After Compline,
    Zaxo

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others meditating upon the Monastery: (4)
As of 2024-12-07 15:36 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Which IDE have you been most impressed by?













    Results (50 votes). Check out past polls.