Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Efficiently selecting a random, weighted element

by jimt (Chaplain)
on Oct 10, 2006 at 15:53 UTC ( #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
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? | Other CB clients
Other Users?
Others browsing the Monastery: (4)
As of 2019-12-12 06:26 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?