First there should be some basic learning of Perl and generally available related things. You should be able to relate a specific skill for specific purpose. Once you have these co-relation in mind practiced, you won't need to remember everytime. The sense of the purpose will make the learning clear and you will continue finding better way to do it. I would call that building a personal expert system.
In this specific example, you were looking for speed. Many other criteria can be applied for better performance at various stages.