Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked

Re: Module Submission for CPAN

by dchetlin (Friar)
on Dec 13, 2000 at 01:57 UTC ( [id://46334]=note: print w/replies, xml ) Need Help??

in reply to Module Submission for CPAN

This is good code and will fill a hole on the CPAN. I was looking for something similar several months ago and came up with nothing.

I have a couple of suggestions that I hope will be helpful.

  • Firstly, I believe there is an alternative data structure that will really speed up your lookups. Here is my suggested algorithm for building it:

    s/\W//g, push @{$dict{join "", sort split //, lc}}, $_ for <DICT>;

    In other words, sort each word and store it in its canonical form in the lookup table, so all anagrams are stored together. Then, when you want to check for anagrams of a word, you just go straight to its canonical key in the hash.

    This might make your starts_word slower/less clear, but I'm not sure. Of course, starts_word won't be necessary for anagram lookups anymore, but it would be a useful standalone function.

  • You'll probably want to do something more robust than assume /usr/dict/words. There are MakeMaker settings to play around with, but I imagine it will be a pain. Somehow, though you'll have to at least make a way for the user to specify where their dictionary is.

  • You probably shouldn't use a global for the lookup table.

  • You don't have to put that initialization code in a BEGIN block.

  • $VERSION is almost always in all caps.

  • Am I missing something, or does walk_dict() not seem to exist?


Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://46334]
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others wandering the Monastery: (6)
As of 2024-04-21 09:18 GMT
Find Nodes?
    Voting Booth?

    No recent polls found