1Data::Random::WordList(U3s)er Contributed Perl DocumentatDiaotna::Random::WordList(3)
2
3
4

NAME

6       Data::Random::WordList - Perl module to get random words from a word
7       list
8

SYNOPSIS

10         use Data::Random::WordList;
11
12         my $wl = new Data::Random::WordList( wordlist => '/usr/dict/words' );
13
14         my @rand_words = $wl->get_words(10);
15
16         $wl->close();
17

DESCRIPTION

19       Data::Random::WordList is a module that manages a file containing a
20       list of words.
21
22       The module expects each line of the word list file to contain only one
23       word.  It could thus be easily used to select random lines from a file,
24       but for coherency's sake, I'll keep referring to each line as a word.
25
26       The module uses a persistent filehandle so that there isn't a lot of
27       overhead every time you want to fetch a list of random words.  However,
28       it's much more efficient to grab multiple words at a time than it is to
29       fetch one word at a time multiple times.
30
31       The module also refrains from reading the whole file into memory, so it
32       can be safer to use with larger files.
33

METHODS

35   new()
36       Returns a reference to a new Data::Random::WordList object.  Use the
37       "wordlist" param to initialize the object:
38
39       •   wordlist - the path to the wordlist file.  If a path isn't
40           supplied, the wordlist distributed with this module is used.
41
42   get_words([NUM])
43       NUM contains the number of words you want from the wordlist.  NUM
44       defaults to 1 if it's not specified.  get_words() dies if NUM is
45       greater than the number of words in the wordlist.  This function
46       returns an array or an array reference depending on the context in
47       which it's called.
48
49   close()
50       Closes the filehandle associated with the word list.  It's good
51       practice to do this every time you're done with the word list.
52

VERSION

54       0.12
55

AUTHOR

57       Originally written by: Adekunle Olonoh
58
59       Currently maintained by: Buddy Burden (barefoot@cpan.org), starting
60       with version 0.06
61
63       Copyright (c) 2000-2011 Adekunle Olonoh.  Copyright (c) 2011-2015 Buddy
64       Burden.  All rights reserved.  This program is free software; you can
65       redistribute it and/or modify it under the same terms as Perl itself.
66

SEE ALSO

68       Data::Random
69
70
71
72perl v5.36.0                      2023-01-20         Data::Random::WordList(3)
Impressum