Skip Menu |

This queue is for tickets about the Data-Random CPAN distribution.

Report information
The Basics
Id: 21353
Status: rejected
Priority: 0/
Queue: Data-Random

People
Owner: Nobody in particular
Requestors: cjensen [...] wcug.org
Cc:
AdminCc:

Bug Information
Severity: Important
Broken in: 0.05
Fixed in: (no value)



Subject: Wordlists in rand_words not cached
In Data::Random::rand_words there's a section that checked whether the wordlist is a reference. Presumably this is so that you can cache wordlists. This section of code doesn't work. It needs to test the reference type to be sure it isn't a file name (SCALAR) and then bless the reference to a Data::Random::WordList object like this: # Check for a pre-existing wordlist object if ( ref( $options{'wordlist'} ) ne 'SCALAR' ) { $wl = $options{'wordlist'}; bless $wl, "Data::Random::WordList"; $close_wl = 0; } In addition to this, Data::Random::WordList should load its wordlist into memory so it doesn't have to read from disk each time it's called. Reading from disk is a big performance hit compared to reading from memory. Since you're already reading the list to get the size, you can chomp each line and push it onto a list reference that you bless onto the class like the filehandle. Here is an example of caching the list: my $list; # Calculate the number of lines in the file my $size = 0; while (<$fh>) { chomp; $list->[$size] = $_; $size++; } # Create the object my $self = bless { 'size' => $size, 'list' => $list, }, $class; Then instead of reading from the filehandle, you can reference directly into the list. If you do that you don't need to keep the filehandle open or bless it.
Hi, I'm the new maintainer of Data::Random. As all of the outstanding RT issues for this module are really old, I'm going through and rejecting them. I figure after all this time, you've probably worked around your problem. :-) In case I'm wrong, though, please feel free to reopen your ticket and I'll take a look at it. Or, you could make it even easier on me by going to GitHub and opening an issue in Data::Random's new repo: https://github.com/barefootcoder/Data-Random/issues Thanks for your bug report, and I'm sorry no one has gotten back to you on it before now.