|Do you know where your variables are?|
Re^5: lhs substr(): refs vs. scalarsby BrowserUk (Pope)
|on Oct 09, 2005 at 04:33 UTC||Need Help??|
The only one substr ref per string bug I was referring to is demonstrated here using 5.6.1:
With the work around being to use string eval to bypass the restriction:
If I remember correctly, the original fix for this went in circa 5.8.3?, but there was another problem also, which I forget the details of, but I will try to remember/retrace my path.
There is (IMO) still an existing problem with lvalue refs in 5.8.5, which I thought I raised a perlbug for, but I have lost track of the outcome. The problem is this:
Once a lvalue ref has been used in a way that shrinks or grows the target string, it appears to loose track of what part of the string it should now be referring to.
Ie. When the lvref that points to substring 20,5, is assigned to by a single char, it continues to refer to a 5 char long substr start at pos 20. Hence, when a second (longer) assignment is done via that same lvref, instead of expanding the string (as it would the first time), it overlays a part of the string that it shouldn't.
I believe it would be both possible, and more correct, for the lvrefs that are assigned to in such a way that they shrink or expand the original string to have their length value adjusted accordingly so that second and subsequent assignments would only overlay that part of the original string that remains after the first assignment.
Ideally, any other lvrefs refering to that part of the string or later parts of the string that would also be affected by the alteration of the strings length would also be adjusted. But I can see that would require keeping track of all lvrefs that point to a given string and inspecting them all each time which would be complex and costly.
But I think adjusting the one assign through would be easy and useful.
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
Lingua non convalesco, consenesco et abolesco. -- Rule 1 has a caveat! -- Who broke the cabal?
"Science is about questioning the status quo. Questioning authority".
The "good enough" maybe good enough for the now, and perfection maybe unobtainable, but that should not preclude us from striving for perfection, when time, circumstance or desire allow.