in reply to Re^4: an algorithm to randomly pick items that are present at different frequencies
in thread an algorithm to randomly pick items that are present at different frequencies
what exactly am I passing to "genPicker"? A file handle?
You answered your own question :) Yes, its a file handle. *DATA is a (pseudo)filehandle that allows access the 'file' after __DATA__.
So,if you had your input in a file called numbs.dat, you do this:
... open my $fh, '<', 'numbs.dat' or die $!; my $pick = genPicker( $fh ); ## Reads the file and generates a picker +subroutine according to its contents. close $fh; ### use $pick->() each time you want a new random number.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^6: an algorithm to randomly pick items that are present at different frequencies
by efoss (Acolyte) on May 27, 2015 at 19:01 UTC | |
by BrowserUk (Patriarch) on May 27, 2015 at 22:33 UTC | |
by efoss (Acolyte) on May 28, 2015 at 04:54 UTC | |
by efoss (Acolyte) on Jun 04, 2015 at 20:30 UTC | |
by BrowserUk (Patriarch) on Jun 04, 2015 at 20:41 UTC | |
by efoss (Acolyte) on Jun 04, 2015 at 21:34 UTC | |
|