Don't worry about golf, the code you look just fine (apart from other answers about using defined ). However, if you find yourself repeating this pattern, everything comes to mind.
The first is, obviously, reorganize it into a utility function, so you have my @list = expand($hit).
The second question is a little deeper - but I like it better than playing golf. The whole point of iterators is to consume them as needed, so if you do this often, are you sure this is really right? Perhaps you are moving this data outside of your own API, so you are limited by other options, but if you have the option of using an iterator rather than a list, this might be a cleaner solution.
ocharles
source share