I'm pretty sure neither of those solutions will work. As the OP stated, the problem is that map returns a list; you are assigning an array to that value. Thus, %res or @_ is not populated until the map returns the whole list (unless you've inserted some magic I'm unaware of.)