Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
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 ( [id://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
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1062421]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others examining the Monastery: (4)
As of 2024-04-25 19:16 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found