Weird,
I believe one could come up with pretty much anything and it'll fit your description. Just the other day I wrote this line of code,
my $max_lines = 100;
. . .
while ($line--) {
. . .
# do stuff
. . .
}
So, basically, variable
$max_lines leaves variable
$line in the dumps if you consider
$line-- as a variable loosing HP, {GRIN}.
UPDATE:
Or how abut this:
my $playera = 100;
my $playerb = 100;
print "player A HP | player B HP\n";
while (1) {
$playera -= rand(10);
$playerb -= rand(10);
print "$playera | $playerb\n";
die (($playera < $playerb) ? "player A lost!" : "player B lost!")
if ($playera < 0 || $playerb < 0);
}
This 'game' playes out as follows:
player A HP | player B HP
94.0023803710938 | 99.3478393554688
88.4292602539063 | 96.0552978515625
88.1494140625 | 94.9520874023438
86.5380859375 | 93.8046264648438
82.1652221679688 | 84.6536254882813
75.5804443359375 | 76.0702514648438
69.7055053710938 | 75.4898071289063
67.3040771484375 | 68.40087890625
63.6215209960938 | 64.7930908203125
58.9315795898438 | 60.8502197265625
50.4647827148438 | 57.1435546875
40.8901977539063 | 49.0029907226563
34.7552490234375 | 39.5355224609375
27.4127197265625 | 33.8937377929688
24.0670776367188 | 31.5869140625
19.4973754882813 | 22.3440551757813
10.3622436523438 | 14.5086669921875
9.0966796875 | 11.1148071289063
7.37579345703125 | 9.4158935546875
2.77679443359375 | 0.14801025390625
-1.7657470703125 | -7.55615234375
player B lost! at temp.pl line 11.
you says:
"The barer the bones, the better"
I guess my code is as 'bare' as you can get (unless some monk out there wants to challange me)! ;-)
_____________________
$"=q;grep;;$,=q"grep";for(`find . -name ".saves*~"`){s;$/;;;/(.*-(\d+)
+-.*)$/;
$_=["ps -e -o pid | "," $2 | "," -v "," "];`@$_`?{print"+ $1"}:{print"
+- $1"}&&`rm $1`;
print$\;}
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.