in reply to Using $1,$2 etc in closures..

Since you declare @args as a lexical outside of the loop and the data structure before the loop, the closures aren't closed over the @args you think they are. :)

I'd pass @res to your data structure, but I'm paranoid about passing backref variables directly. It bit me in Regex::English or Test::MockObject at least once.