Well, i admit it: it's a really strange script...
Today i was on the beach. Now that September has come, surfers rule the beach 'cos this weather makes surf possible here in my hometown.
I usually go to the beach with a friend of mine, and we spend hours talkin' about computers, programming and unix systems, glancing at girls and wondering why should they be interested in such a geek beings...
So, there was a longboard contest there, and we were kidding those strained surfers trying to ride two-feet-tall waves and spending a whole lot of muscles in vain; what a poor task was theirs...
Suddenly Icchio a.k.a. Matteo (my friend) had a silly great idea: "Why don't you code a Perl script which surfs for you?" <KIDDING ME>
This is what i did: i took my Camel Book out of my sack (yes, i DO carry with me on the beach the Camel Book)(really) and coded this script that, as usual, is warning safe and strict compliant!
You can use it when you gotta choose something by chance: each guy runs the script and who scores best decides!
Enjoy!
#!/usr/bin/perl -w
use strict;
my ($waves, $board, $ride, $score);
$board = int (rand 5);
print "Your board is pretty good! Go ride, Master!\n\n"
if $board <= 1;
print "Poor Lamer...Where d'ya wanna go with that board?\n\n"
if $board >= 4;
print "Got a good old standard longboard! Enjoy!\n\n"
if $board == 2 || $board == 3;
sleep 1;
$waves = 5;
$score = 0;
while ($waves != 0)
{
$waves = int (rand 9);
if ($waves == 0)
{
print "No more waves, the tide has gone...\n";
print "Today's score is: ", $score, "\n";
last
}
$ride = ($waves - $board);
$score++, $score++, print "Damn good ride!\n" if $ride >= 3;
$score++, print "Fine ride!\n"
if $ride < 3 && $ride >= (-2);
print "Loser!\n" if $ride < (-2);
if ($ride <= (-4))
{ print "You're gonna break your neck!\n";
++$board;
}
sleep 1;
}
SiG
perl -le 's ssSss.s sSsSiss.s s$sSss.ss .$s\107ss.print'
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.