Beefy Boxes and Bandwidth Generously Provided by pair Networks
Come for the quick hacks, stay for the epiphanies.
 
PerlMonks  

Re (tilly) 1: Quine Whine

by tilly (Archbishop)
on Mar 06, 2001 at 22:16 UTC ( [id://62528]=note: print w/replies, xml ) Need Help??


in reply to Quine Whine

Hmmm...people don't seem to be interested in making them. Ah well. Here is a quine that shows a standard form that you can usually get to work...
# This is a quine. $c = "# This is a quine. "; $t = q(-c$c = "-c"; $t = q(-t); # Note the repeated text here. This appears both in data # and in source. Anything you want can go here as long # as it repeats and you do not interfere with these actions... # Substitute the variables back into the data. If you do # not like symbolic refs, you could use a hash instead, same # diff. This substitution builds source out of data. $t =~ s/-(\w+)/${$1}/g; # Since data is now source, just print it and we are done. print $t; ); # Note the repeated text here. This appears both in data # and in source. Anything you want can go here as long # as it repeats and you do these actions... # Substitute the variables back into the data. If you do # not like symbolic refs, you could use a hash instead, same # diff. This substitution builds source out of data. $t =~ s/-(\w+)/${$1}/g; # Since data is now source, just print it and we are done. print $t;
Of course it is also quite possible to make jokes that are quines. In fact I already did with the rather degenerate shortest one above. And here is another joke quine:
# This is a quine two :-) undef $/; $_ = <DATA>; print; print; __DATA__ # This is a quine two :-) undef $/; $_ = <DATA>; print; print; __DATA__
(Come on, give it a try. Quines are really quite fun. :-)

Replies are listed 'Best First'.
Re: Re (tilly) 1: Quine Whine
by danger (Priest) on Mar 06, 2001 at 22:30 UTC

    Well, here is an old standby:

    $_=q(print qq(\$_=q($_);eval\n));eval

    And here is a clever one I originally saw ages ago on clpm (posted by mjd I think, but I could be wrong about that). Save the following line to a file named "/tmp/p" and run as: perl /tmp/p

    Illegal division by zero at /tmp/p line 1.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others goofing around in the Monastery: (4)
As of 2024-04-20 01:59 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found