This is exactly the point the question is not clear to me. The question sound a bit like "I'm singing" and "I'm dancing" what's faster? The difference between return value and print out to the screen is less in terms of speed but much more in terms of what are going to do? If you are happy with printing the result of the sub to the screen - go on there is nothing wrong with it and there is also no need to return the result to a caller and print it there. But if you want to collect the results of the calculation and do furher processing maybe an average of multiple runs or save it to the database there is the only way to pass a value back to the caller and printing to a screen is completely useless.

In reply to Re^4: Print Vs Return In a Subroutine by wwe
in thread Print Vs Return In a Subroutine by remya

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.