http://qs1969.pair.com?node_id=403981


in reply to Is it computationally expensive to return a large string (50-100 kB) from a sub?

However, when passing large strings as arguments to a sub, perl internally puts a pointer to the string on the stack (rather than the value itself). Using references (and later accessing the data indirectly) can actually be slower than passing the original string, but the difference is much smaller than that from the example above.

Note, though, that this doesn't mean you should flatten non-scalar data when designing your subs. When passing an array or a hash with many members, use a reference.