Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

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

by ig (Vicar)
on Nov 13, 2013 at 17:29 UTC ( #1062421=note: print w/replies, xml ) Need Help??


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;

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1062421]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (4)
As of 2020-09-18 14:49 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    If at first I donít succeed, I Ö










    Results (112 votes). Check out past polls.

    Notices?