Beefy Boxes and Bandwidth Generously Provided by pair Networks Bob
We don't bite newbies here... much
 
PerlMonks  

fortune

by BastardOperator (Monk)
on Nov 16, 2000 at 18:49 UTC ( #41967=sourcecode: print w/ replies, xml ) Need Help??

Category: fun stuff
Author/Contact Info BastardOperator
Description: fortune program, nuff said.
I just had to post this, not because of the code (~5 lines), but because of the quotes. They crack me up. :)
#!/usr/bin/env perl -w

use strict;

my $quip    =    "";
{
    $/ = "%%\n";
    rand($.) < 1 && chomp($quip = $_) while(<DATA>);
}
print "\n$quip\n" || "Could not get quote\n";


__END__
Ask me about my vow of silence
%%
Death is nature's way of telling you to slow down.
%%
Hail to the Sun God! He is the Fun God! Ra! Ra! Ra!
%%
I WENT THROUGH HELL!!! (Elvis says Hi!)
%%
I am the mother of all things, and all things should wear a sweater
%%
If one synchronized swimmer drowns, do the rest have to drown too?
%%
If today is the first day of the rest of your life, what was yesterday
+?
%%
If pi were 3, this sentence would look like this.
%%
Is the glass half empty, half full, or twice as large as it needs to b
+e?
%%
It doesn't matter what temperature a room is it's always room temperat
+ure.
%%
Jesus died for your sins. Make it worth his time.
%%
Smash forehead on keyboard to continue.
%%
The way to a man's heart is through his back.
%%
There are more ways of killing a cat than buttering it with parsnips.
%%
There are three kinds of people -- those who can count, and those who 
+can't.
%%
Time flies like an arrow, fruit flies like bananas
%%
There is a fine line between falling and flying.
%%
If Milli Vanilli falls down in the woods, does someone else make a sou
+nd?
%%
There's more than one way to skin a cat. Way #15: Krazy Glue and a too
+thbrush.
%%
If you hear an onion ring, answer it.
%%
Eagles may soar free and proud, but weasels never get sucked into jet 
+engines.
%%
[Warning on knife]:  Caution.  Blade is sharp.  Keep out of children.
%%
Q: Where does virgin wool come from?  A: Ugly sheep.
%%
Of all the things I've lost, I miss my mind the most.
%%
There are two major products to come out of Berekley:  LSD and UNIX.
%%
Save the whales.  Collect the whole set.
%%
Jesus saves...but Gretzky gets the rebound!  He shoots.  HE SCOOORES!
%%
God is real, unless declared as an integer.
%%
Death:  To stop sinning suddenly.
%%
Be different:  Conform.
%%
Paul's law:  You can't fall off the floor.
%%
Sex is not the answer.  Sex is the question.  "Yes" is the answer.
%%
Now let's all repeat the non-conformist oath.
%%
Today is the yesterday you worried about tomorrow.
%%
No matter where you go, there you are.  -- Buckaroo Banzai
%%
Useless advice #986:  Never sit on a tack.
%%
A day without sunshine is like night.
%%
College is a fountain of knowledge...and the students are there to dri
+nk.
%%
A polar bear is a rectangular bear after a coordinate transform.
%%
This is a crude version of a more advanced utility that has never been
+ written.
%%
--------- if you cut here, you'll probably destroy your monitor ------
+----
%%
Cole's Law:  Thinly sliced cabbage.
%%
Photons have mass?  I didn't know they were catholic!
%%
Jesus saves sinners...and redeems them for valuable cash prizes!
%%
God is love; Satan is 30 and up one set.
%%
A man without religion is like a fish without a bicycle.
%%
What was sliced bread the greatest thing since?
%%
I haven't lost my mind; I'm sure it's backed up on tape somewhere!
%%
The use of 'goto' statements is discouraged, especially with the label
+ HELL:
%%
If God had intended Man to Smoke, He would have set him on Fire.
%%
Never hit a man with glasses.  Hit him with a baseball bat.
%%
If the phone doesn't ring, it's me.
%%
That was Zen.  This is Tao.  -- Peter da Silva
%%
Where would we be without rhetorical questions?
%%
Illiterate?  Write for help!
%%
Ninety percent of the game is half mental.  -- Yogi Berra
%%
Two rights don't make a wrong, but three will get you back on the free
+way.
%%
Heisenberg may have been here.
%%
There are too many states.  Please eliminate three.  I am not a crackp
+ot.
%%
What I look forward to is continued immaturity followed by death.
%%
Television:  A medium.  So called because it is neither rare nor well 
+done.
%%
Never trust anybody who says "trust me."  Except just this once, of co
+urse.
%%
We now present the conclusion of...The Never-ending Story.
%%
Playing a billion in a row on KRQR, the station that doesn't count too
+ good.
%%
If God didn't want us to eat animals, then how come he made them out o
+f meat?
%%
Beware the lollipop of mediocrity.  Lick it once and you will suck for
+ever.
%%
Never hunt rabbit with dead dog.  -- Charlie Chan
%%
If at first you don't succeed, skydiving is not for you.
%%
Inbreeding is how we get championship horses.
%%
Insanity runs in my family.  It practically gallops.
%%
Half of the people in the world are below average.
%%
There's so much comedy on television.  Does that cause comedy in the s
+treets?
%%
The number you have dialed is imaginary.  Please divide by 0 and try a
+gain.
%%
Writing about music is like dancing about architecture.
%%
On a tombstone:  "I TOLD YOU I WAS SICK"
%%
I still miss my ex wife, but my aim is getting better
%%
Animal testing is wrong, they get all nervous and give wrong the answe
+rs
%%
Teamwork is essential, it gives the enemy someone else to shoot at
%%
Madness takes it's toll, please have exact change
%%
It is possible for your mind to be so open your brain falls out
%%
If we can put a man on the moon, why can't we put metal in a microwave
+!
%%
The human spirit is a very hard thing to kill.  Even with a chainsaw.
%%
Roses are red. Violets are blue. Some poems rhyme. But this one doesn'
+t.
%%
Why doesn't the fattest man in the world become a hockey goalie?
%%
Here's to our wives and girlfriends...may they never meet!
%%
I've had a perfectly wonderful evening.  But this wasn't it.
%%
Under capitalism, man exploits man.  Under communism, it's just the op
+posite.
%%
If at first you don't succeed, destroy all evidence that you tried.
%%
For every complex problem, there is a solution that is simple, neat, a
+nd wrong.
%%
Do you think sheep know when you're pulling the wool over their eyes?
%%
...and always remember the last words of my grandfather, who said "A t
+ruck!"
%%
You can't have everything.  Where would you put it?
%%
On the other hand the early worm gets eaten
%%
Vote for the man who promises least; he'll be least disappointing
%%
The speed of time is one second per second
%%
If I'd Shot You Sooner, I'd Be Out of Jail by Now
%%
668 -- the neighbor of the beast.
%%
A signature always reveals a man's character -- and sometimes even his
+ name
%%
All my life I wanted to be someone. I guess I should have been more sp
+ecific
%%

Comment on fortune
Download Code
Re: fortune
by AgentM (Curate) on Nov 16, 2000 at 23:08 UTC
    'cuse me! You forgot to implement the caesar encryption on the fortunes! That's 80% of the meat in the program! (Also, you should be able to load different fortune "modules"!) You've drained the fun out of fortune! :-) But ++ anyway.
    AgentM Systems nor Nasca Enterprises nor Bone::Easy nor Macperl is responsible for the comments made by AgentM. Remember, you can build any logical system with NOR.
Re: fortune
by FouRPlaY (Monk) on Nov 16, 2000 at 23:58 UTC
    I wish I could ++ this several times. Those sayings cracked me up!



    FouRPlaY
    Learning Perl or Going To Die Trying
      hee hee, I know, I just can't stop giggling everytime I look at 'em.
Re: fortune
by zeno (Friar) on Jan 26, 2001 at 14:45 UTC

    Great job on this! I just added this line:
    print "Content-Type: text/html\n\n";
    as the first line of the script, put the resulting script into my cgi-bin, and set the resulting URL as my startup page for my browser. Now I get strange fortune wisdom every time I fire up my browser! Thanks for making my day just a little more surreal!

      Why are you giving it a content type of text/html? Looks like text/plain would be more appropriate - unless to want to change the script to actually output some HTML!

      --
      <http://www.dave.org.uk>

      "Perl makes the fun jobs fun
      and the boring jobs bearable" - me

        davorg is right! So I modified my original, um, modification to include some nice HTML formatting to it. Here's the new code. Thanks davorg for getting me to fix it! -timallen
        #!/usr/bin/env perl -w use strict; my $quip = ""; { $/ = "%%\n"; rand($.) < 1 && chomp($quip = $_) while(<DATA>); } print "Content-Type: text/html\n\n"; print "<html><head><title>Fortune Teller Says...</title></head>"; print "<body bgcolor=#CCFFFF>"; print "<h3>$quip</h3>" || "<font color=FF0000>Could not get quote</fon +t>"; print "</body></html>"; __END__
        ... followed by the original (hilarious) quips!

Back to Code Catacombs

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (11)
As of 2014-04-16 12:01 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    April first is:







    Results (425 votes), past polls