in reply to Re^3: [SOLVED] Return statement in subroutine(s) is necessary when not returning anything?
in thread [SOLVED] Return statement in subroutine(s) is necessary when not returning anything?

Indeed.

But my point was just because a lot of people do something, really doesn't have any bearing on it being a good - or bad - practice. Argumentum ad populum

Especially in perl, which lets you get away with all sorts of horrific nastiness for extended periods of time.

  • Comment on Re^4: [SOLVED] Return statement in subroutine(s) is necessary when not returning anything?

Replies are listed 'Best First'.
Re^5: [SOLVED] Return statement in subroutine(s) is necessary when not returning anything?
by ikegami (Patriarch) on Nov 06, 2015 at 18:55 UTC

    I didn't say "lot of module use the practice"; I said "lots of that modules that work perfectly fine use the practice". When the argument against the practice is that cause things to malfunction, this isn't argumentum ad populum.

Re^5: [SOLVED] Return statement in subroutine(s) is necessary when not returning anything?
by Your Mother (Archbishop) on Nov 06, 2015 at 13:28 UTC

    The opposite is also true. Just because something is rarely used doesn't make it a good practice. Nearly no one really means just that. You can argue that nearly every single author on CPAN writes shoddy code 100% of the time but I don't think the argument has much traction. :P

    Returning to the OP and the theme at hand. Printing from subroutines is a poor practice. They should return data for the controller (program flow) to use. Printing from a sub breaks its extensibility, limits its usefulness, and encourages code duplication (by avoiding view/template practices and making things impossible to reuse as is).