The stupid question is the question not asked | |
PerlMonks |
Re: Memory Leak when using Lingua::EN::MatchNamesby allolex (Curate) |
on May 04, 2004 at 21:41 UTC ( [id://350587]=note: print w/replies, xml ) | Need Help?? |
I've tried to improve your code, and I have tested what I am posting here. You have a couple of problems. The first one is that you are creating a number of unnecessary arrays with your extra foreach loops. I've tried to optimize that by using keys with hashes as opposed to creating temporary lookup arrays, and then creating a subroutine to handle reading in the files, etc. When you're done with a file, it is a good idea to close it to avoid leaving dangling filehandles. The other thing has already been pointed out. If you look at the Lingua::EN::MatchNames documentation, you can see it expects fn1, ln1, fn1, ln2. I fixed that, kind of (see my comment). The name_eq() function will return undef if there is no possible match, so I adding handling for that as well. That accounts for the "uninitialized value" warnings.
Best of luck to you.
--
In Section
Seekers of Perl Wisdom
|
|