Thanks for your comments but further tests do show a difference. Here is what I've used:
"out1ax$len" => sub { for (1 .. COUNT) { $tmp = out1() } }, "out1bx$len" => sub { for (1 .. COUNT) { $tmp = \out1() } }, "out2ax$len" => sub { for (1 .. COUNT) { $tmp = ${ out2() } } }, "out2bx$len" => sub { for (1 .. COUNT) { $tmp = out2() } },
And here is what it gives:
 out1ax100: 44 wallclock secs (43.20 usr +  0.01 sys = 43.21 CPU) @  0.23/s (n=10)
 out1bx100: 42 wallclock secs (42.03 usr +  0.01 sys = 42.04 CPU) @  0.24/s (n=10)
 out2ax100: 41 wallclock secs (40.59 usr +  0.00 sys = 40.59 CPU) @  0.25/s (n=10)
 out2bx100:  2 wallclock secs ( 1.61 usr +  0.00 sys =  1.61 CPU) @  6.21/s (n=10)
So out2b (real return by reference) is much faster than out1b (take the reference of the result). So string copy does take place when Perl handles the return value of the function. Or did I miss something?

In reply to Re^2: How to avoid string copies in function calls? by Anonymous Monk
in thread How to avoid string copies in function calls? by Anonymous Monk

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.