in reply to Optimize debugging subs
You'd want to prefer use constant to sub ... () { ... }. Perl core keeps constant more up to date with what's right for the version that's running your perl than your code will ever be. For instance, the 5.9.3+ version is best expressed in a manner *other* than a simple sub ... () { ...}. If you use constant, perl will do the right thing for the perl version you're using. If you're doing it by hand, you may be doing it suboptimally.
Oh yeah, forget your idea of the "elegant" version. It's just going to be more overhead than the DEBUG && foo(...);/foo(...) if DEBUG; version because it can't avoid calling foo(...). Perl doesn't know that &foo won't be redefined later so it's left as a function call.
⠤⠤ ⠙⠊⠕⠞⠁⠇⠑⠧⠊
|
|---|