There are many ways to get perl to consume all available memory -- and some, like the method discussed here -- are quick and easy. Well, heck, these things happen, and "a good way to avoid them" is, as you have said, to keep thing simple and not code wrong.