[EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > En op 08 april 2002 sprak Keith Calvert Ivey:
> > #!perl > > map$%{join _,sort/./g}.=$_,sort<>;map$_[s/ > > ^/ /gm].=$_,sort%%;print@_[1..$=] > > > > I'm using ActiveState's Perl 5.6.1, build 626, so maybe it's a > > Windows thing. > > Nope. I hit the same brick wall and tried it on Linux as well > where it failed with 'out of memory'. I asked Dave to try it and > it blew up for him too. I thought it was a Perl bug, but I was > too fatigued and frustrated at the time for any sort of rational > analysis. Actually now that I think about it, I don't think it's really a bug. It's just a lack of optimization that affects Abigail and other people who use map() in a void context. When you have a list of 5000 words averaging 8 characters each, most of which aren't anagrams, that second map() constructs a pretty big list of values that ends up getting thrown away (over 400 MB of string data, not counting overhead for how Perl stores it). The first map() also uses some memory, though that should be freed once the statement is finished, since it's not being saved. And of course the hash and the sorted copy of the hash and the array all use significant amounts of memory too. Perl isn't optimized to conserve memory, after all, especially for hashes. It's not surprising that the memory usage exceeds 1 GB. -- Keith C. Ivey <[EMAIL PROTECTED]> Washington, DC