<?xml version="1.0" encoding="windows-1252"?>
<node id="225271" title="Use radio noise to make (non-critical) decisions..." created="2003-01-08 10:03:47" updated="2005-07-27 18:35:52">
<type id="1042">
CUFP</type>
<author id="159771">
dbush</author>
<data>
<field name="doctext">
&lt;P&gt;Ever had the problem of not knowing what to do? Perl and &lt;A HREF=http://www.random.org/essay.html&gt;random.org&lt;/A&gt; to the rescue...&lt;/P&gt;

&lt;CODE&gt;
use strict;
use warnings;
use LWP::Simple;

my ($szConumdrum, $szThisSolution, @solution, $URL, $iRandom);

print 'Conundrum: ';
chomp ($szConumdrum = &lt;STDIN&gt;);

while () {
	print 'Solution:  ';
	chomp ($szThisSolution = &lt;STDIN&gt;);
	last if $szThisSolution eq '';
	push @solution, $szThisSolution;
}

$URL = "http://www.random.org/cgi-bin/randnum?num=1&amp;min=0&amp;max=$#solution&amp;col=1";

print "Deciding...\n";
$iRandom = get($URL);
die "Unable to decide!\n" if not defined $iRandom;

print "The solution to '$szConumdrum' is '$solution[$iRandom]'\n";

__END__
&lt;/CODE&gt;

&lt;P&gt;I was in two minds about posting this code and so I thought I would ask the script itself. The following is honestly the result...&lt;/P&gt;

&lt;CODE&gt;
Conundrum: Should I post this code to PM?
Solution:  Yes
Solution:  No
Solution:
Deciding...
The solution to 'Should I post this code to PM?' is 'Yes'
&lt;/CODE&gt;

&lt;P&gt;The ether can't be wrong.&lt;/P&gt;

&lt;P&gt;Cheers,&lt;BR&gt;
Dom.
&lt;/P&gt;

&lt;P&gt;
&lt;SMALL&gt;
&lt;B&gt;Update:&lt;/B&gt; Changed the code based on [id://170442]'s suggestion in the chatterbox; "you should probably use $#solution, rather than @solution - 1. And you can interpolate it directly".
&lt;/SMALL&gt;
&lt;/P&gt;</field>
</data>
</node>
