Please use [brackets around links] to make them clickable

I don't understand your question, http://perldoc.perl.org/5.20.0/perldelta.html#Performance-Enhancements and the passage you cite are pretty clear.

In some language like JS strings are immutable°, which means you can optimize the assignment by simply sharing the (internal) reference, only if one of the copies is changed you'll need to allocate new space for the cloned and changed content.˛

This has performance advantages if copies are rarely changed, and strings can become very long in Perl.

Perl has mutable strings, the reference of a scalar will point to the changed container.

NB: JS has no (external) references of so called "primitive types" (read scalars), i.e. no reference \$var operator at all. And JS doesn't have any "aliasing", where manipulating $_[0] will change the passed arguments of a sub.

Cheers Rolf
(addicted to the Perl Programming Language and ☆☆☆☆ :)
Wikisyntax for the Monastery

UPDATES

°) https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures

Unlike in languages like C, JavaScript strings are immutable. This means that once a string is created, it is not possible to modify it. However, it is still possible to create another string based on an operation on the original string.

˛)

your example in JS:

var s = "foo"; var t = s; s += "bar";

means a new string s + "bar" constructed, allocated in memory and linked to the symbol s.

But in older Perl Versions $s and $t point to different memory locations, and the $s.="bar" means 3 letters are appended to the buffer holding the characters of $s. (if there is buffer space left)


In reply to Re: perl string pass by value by LanX
in thread perl string pass by value by pwagyi

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.