1Random::WordList(3)   User Contributed Perl Documentation  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.05
55

AUTHOR

57       Adekunle Olonoh, koolade@users.sourceforge.net
58
60       Copyright (c) 2000 Adekunle Olonoh. All rights reserved. This program
61       is free software; you can redistribute it and/or modify it under the
62       same terms as Perl itself.
63

SEE ALSO

65       Data::Random
66

POD ERRORS

68       Hey! The above document had some coding errors, which are explained
69       below:
70
71       Around line 158:
72           =back doesn't take any parameters, but you said =back 4
73
74
75
76perl v5.12.1                      2003-02-22               Random::WordList(3)
Impressum