Just another Perl shrine | |
PerlMonks |
Re: Memory issue with large array comparisonby Eliya (Vicar) |
on May 24, 2012 at 21:21 UTC ( [id://972325]=note: print w/replies, xml ) | Need Help?? |
The task doesn't require that you have all pathnames in memory at once. It can just as well be solved by processing one path at a time. So, for example, read them one by one from a file
That should significantly cut down on memory usage. Also, iterative solutions (plain old nested loops) are generally less memory hungry than functional implementations (grep, map and friends) of the same task. This is because the former avoid creating additional lists on the stack. BTW, do you really need the regex /$_\w+$/, i.e. wouldn't a simple hash lookup (of the appropriate path fragment) work, too?
In Section
Seekers of Perl Wisdom
|
|