http://qs321.pair.com?node_id=135403


in reply to Re: Perl's pearls
in thread Perl's pearls

Your script is very elegant, shorter and functionally equivalent.
However, this simplicity comes at a price. The overhead of a second hash to eliminate duplicates is a heavy load on performance, especially after adding "use strict" and "-w" on top.
I compared the execution times on a 102_759 words dictionary.
$ time perl gmax_anagram.pl < words |wc 4.26user 0.07system 0:04.32elapsed 6427 14802 107910 $ time perl merlyn_anagram.pl < words |wc 6.35user 0.10system 0:06.45elapsed 6427 14802 107910 (after adding use strict and -w) $ time perl merlyn_anagram.pl < words |wc 7.44user 0.12system 0:07.55elapsed 6427 14802 107910
Anyway, this approach is one more thing to know, if I want to privilege a shorter script in favor of a faster one.
Thanks.
 _  _ _  _  
(_|| | |(_|><
 _|