Well said, LanX.
So would it be true to say that when taking such "exact" copies of a string, you can modify the copy without affecting the original, but this is not the case when taking such "exact" copies of things like hash keys & values, because the copy will be some kind of reference to the original? | [reply] [Watch: Dir/Any] |
Well said, LanX.
Well, it wasn't LanX, but...
... when taking such "exact" copies of a string, you can modify the copy without affecting the original ...
Yes, because in the case of x, scalars (e.g., strings) are copied (and concatenated) by value, so the copy is independent.
... this is not the case when taking such "exact" copies of things like hash keys ...
Hash keys are strings (scalars).
... & values, because the copy will be some kind of reference to the original?
The value of a hash key/value pair (or item of an array (update: or list)) is always a scalar. A scalar can be a reference. (A reference is always a scalar.) Operator x copies things exactly, but two or however many exact copies of a given reference always point to a single thing: the "referent". A referent may be referenced by any number of references. (Update: See reference, perlref, perlreftut, and perldsc.)
Give a man a fish: <%-{-{-{-<
| [reply] [Watch: Dir/Any] [d/l] [select] |
OK, thanks again AnomalousMonk, and sorry for renaming you to LanX. (Where's the "unrename" function when I need it?)
| [reply] [Watch: Dir/Any] |