Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Efficiently selecting a random, weighted element

by jimt (Chaplain)
on Oct 10, 2006 at 15:53 UTC ( [id://577433]=CUFP: print w/replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    
    my @files = qw(file_a.txt file_b.txt file_c.txt file_d.txt file_e.txt)
    +;
    
  2. or download this
    
    my %words_in_files = (
    ...
        'file_e.txt'    => 10
    );
    
  3. or download this
    
    aaaaaaaaaabcccdddddeeeeeeeeee
    
  4. or download this
    
    my @indexes_of_files = (
    ...
    
    my $total_number_of_words = 29;
    
  5. or download this
    
    my @indexes_of_files = (
    ...
    
    my $total_number_of_words = 24;    #previously 29
    

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: CUFP [id://577433]
Approved by Corion
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others imbibing at the Monastery: (5)
As of 2024-04-24 10:35 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found