in reply to Closures clarification
Secondly in a closure you have access to a variable in an outer scope, which is "enclosed" in the sub (hence the name), in your first example $total_size.