in reply to call external sub ref from method in single line

Last time I checked, ASCII characters were still free.   And, last time I checked, computer programmers were not.

Also, most of those programmers are not spending their days writing new code.   They are wrestling with existing, revenue-producing code bases (“legacy code”) which might be decades old and worked-on by more than a hundred different people over those years.

Therefore, what’s really most-important in your source code is:   clarity.   For instance, using a more meaningful name than sub_ref, and maybe deliberately using a local variable (named, say, $ajaxRequestCallback instead of $pSub ...) to clarify to the next guy exactly what it is you’re calling and why.   (And if his future modification, written three years after you got smooshed by that most-unfortunate bread truck, needed to call the subroutine twice or under slightly different conditions, your “wasteful” use of a few extra lines or characters will have helped him a little.)

Not meaning to preach here ... (honest) ... but over these years I have just seen so much “cleverness,” and in so many different languages.   Clarity and simplicity in the original coding makes a high-dollar difference in the sort of “project turn-around, I See Dead Projects™” work that I do so much of.   Speaking therefore as the one who cleans up after you:   “Please don’t try to economize on bytes or lines.   Ever.   Instead, make it as easy as possible for us to read your mind, given that we cannot dig you up to ask.”   Thank you.   ;-)

Replies are listed 'Best First'.
Re^2: call external sub ref from method in single line
by Laurent_R (Canon) on Oct 05, 2015 at 18:03 UTC
    That's a knee-jerk reaction.

    Sometimes, short and concise code is clearer than long code (and that's why I prefer Perl to Java or Ada), and sometimes not.

    Granted, clarity is of paramount importance, but long code is no guarantee for clarity, really not. (And no, I am not advocating golfing.)

        What a terrible post!

        After all this time, you still can't write a syntactically correct anonymous internet slur.

        • 'posting on perlmonks' - Perhaps you meant 'PerlMonks,' the proper noun?
        • 'valid line of perl' - Perhaps you meant 'Perl' the language, not 'perl' the interpreter?
        • 'code that uses grep golfing' - Perhaps you meant 'code, which uses grep, "golfing"', or maybe you simply eschew punctuation at unpredictable moments. Stack overload inside your cranium?
        • 'hes stupid' - Perhaps you meant 'he's stupid.'?
        • 'a non-programming piece of poo' - Perhaps you meant to say that the Monk in question has no redemptive value because 'he still can't write a valid line of perl' (an overstated assertion and a hyperbolic conclusion even if you were trying to be mean)? If so, perhaps you should consider your linguistic shortcomings in your native language that you so succinctly have placed on display here.

        The way forward always starts with a minimal test.