in reply to Re^2: Passing anon sub as param
in thread Passing anon sub as param
I personally think that the anon-sub call back is just cleaner looking, but it has a number of other benefits. The biggest of those is that it doesn't break or force you to do ugly things if traverse is in another package.
Other benefits: you don't clutter up your symbol table with global named functions that are only intended to be used in one place. Also: you can use traverse in different ways in the same application, rather than defining the callback globally.
I also think that defining a fallback is cleaner in this case: you just check the $code arg for definedness, rather than probing the caller's package. Scope is nice and closed.
|
|---|