<?xml version="1.0" encoding="utf-8" ?><rss version="2.0" xml:base="https://www.webmaster-forums.net/crss/node/1011994" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title></title>
    <link>https://www.webmaster-forums.net/crss/node/1011994</link>
    <description></description>
    <language>en</language>
          <item>
    <title></title>
    <link>https://www.webmaster-forums.net/serverside-scripting/generate-random-number-specific-weight#comment-1069220</link>
    <description> &lt;p&gt;To tell the truth, I&#039;m having a lot of problems trying to...don&#039;t get me wrong; I&#039;m good at PERL, but as a CGI language, and not as just a regular one.  This book takes for granted that I am used to typing ym code right into the interpretuer (sp?), which I&#039;m not.  I&#039;ve been trying to figure this out since you posted your message a few days ago.  &lt;img src=&quot;https://www.webmaster-forums.net/misc/smileys/surprise.png&quot; title=&quot;Shocked&quot; alt=&quot;Shocked&quot; class=&quot;smiley-content&quot; /&gt;&lt;/p&gt;
&lt;p&gt;You said you didn&#039;t want to code but that&#039;s the best I could to (I found the info online somewhere, but lost it, otherwise I would point you to that):&lt;/p&gt;
&lt;p&gt;&lt;div class=&quot;codeblock&quot;&gt;&lt;code&gt;sub weight_to_dist {&lt;br /&gt; my %weights = @_;&lt;br /&gt; my %dist = ();&lt;br /&gt; my $total = 0;&lt;br /&gt; my ($key, $weight);&lt;br /&gt; local $_;&lt;br /&gt; foreach (values %weights) {&lt;br /&gt;&amp;nbsp; $total += $_;&lt;br /&gt; }&lt;br /&gt; while ( ($key, $weight) = each %weights ) {&lt;br /&gt;&amp;nbsp; $dist{$key} = $weight/$total;&lt;br /&gt; }&lt;br /&gt; return %dist;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;sub weighted_rand {&lt;br /&gt; my %dist = @_;&lt;br /&gt; my ($key, $weight);&lt;br /&gt; while (1) {&lt;br /&gt;&amp;nbsp; my $rand = rand;&lt;br /&gt;&amp;nbsp; while ( ($key, $weight) = each %dist ) {&lt;br /&gt;&amp;nbsp;&amp;nbsp; return $key if (rand -= $weight) &amp;lt; 0;&lt;br /&gt;&amp;nbsp; }&lt;br /&gt; }&lt;br /&gt;}&lt;/code&gt;&lt;/div&gt;&#039;&lt;/p&gt;
&lt;p&gt;I don&#039;t know what to pass to it (I tried several things, none worked), and my best guys is that $key is the rand number it produces.  If you figure anything out, please tell me! &lt;img src=&quot;https://www.webmaster-forums.net/misc/smileys/big.png&quot; title=&quot;Laughing out loud&quot; alt=&quot;Laughing out loud&quot; class=&quot;smiley-content&quot; /&gt;&lt;/p&gt;
&lt;p&gt;Richard&lt;/p&gt;
 </description>
     <pubDate>Fri, 11 Aug 2000 06:00:18 +0000</pubDate>
 <dc:creator>richjb</dc:creator>
 <guid isPermaLink="false">comment 1069220 at https://www.webmaster-forums.net</guid>
  </item>
  <item>
    <title></title>
    <link>https://www.webmaster-forums.net/serverside-scripting/generate-random-number-specific-weight#comment-1069218</link>
    <description> &lt;p&gt;I don&#039;t have that book, so if you have time, please grasp the basic idea. I really love to know it!!&lt;/p&gt;
&lt;p&gt;I don&#039;t need the code, since I think I might code it in PHP. The algorithm is most important for me. Thanks for your help in advance! &lt;img src=&quot;https://www.webmaster-forums.net/misc/smileys/smile.png&quot; title=&quot;Smiling&quot; alt=&quot;Smiling&quot; class=&quot;smiley-content&quot; /&gt;&lt;/p&gt;
 </description>
     <pubDate>Fri, 11 Aug 2000 05:06:37 +0000</pubDate>
 <dc:creator>123finder.com</dc:creator>
 <guid isPermaLink="false">comment 1069218 at https://www.webmaster-forums.net</guid>
  </item>
  <item>
    <title></title>
    <link>https://www.webmaster-forums.net/serverside-scripting/generate-random-number-specific-weight#comment-1069215</link>
    <description> &lt;p&gt;Recipe 2.11 of the CGI/PERL Cookbook covers what you want to do...but I&#039;m not sure of how it works, and am not sure if I can post the code.&lt;/p&gt;
&lt;p&gt;Richard&lt;/p&gt;
 </description>
     <pubDate>Fri, 11 Aug 2000 04:43:49 +0000</pubDate>
 <dc:creator>richjb</dc:creator>
 <guid isPermaLink="false">comment 1069215 at https://www.webmaster-forums.net</guid>
  </item>
  </channel>
</rss>
