http://qs321.pair.com?node_id=1062421


in reply to Re^2: Help with proper construction of callable scalars from a Module, please.
in thread Help with proper construction of callable scalars from a Module, please.

Is there any reason I shouldn't use the return statements I've just chosen?

I think returning the data has the advantage that the caller can decide what to do with it: print it to STDOUT or any other file handle, write it to a database, change the character encoding or otherwise modify it, etc.

If the sub prints it, you could add an optional filehandle argument so it can be redirected, and you could print it to a scalar, thereby, but, in my opinion only, this would be more complicated for, at best, very little advantage.

  • Comment on Re^3: Help with proper construction of callable scalars from a Module, please.

Replies are listed 'Best First'.
Re^4: Help with proper construction of callable scalars from a Module, please.
by taint (Chaplain) on Nov 13, 2013 at 19:11 UTC
    Thank you for the thorough evaluation ig.
    That's what I was wondering. I've since updated it (at the bottom of this thread).

    Best wishes, and thanks again.

    --Chris

    #!/usr/bin/perl -Tw
    use Perl::Always or die;
    my $perl_version = (5.12.5);
    print $perl_version;