in reply to An Oddity of substr
I think this is the same anomaly as I noticed at [substr] anomaly or mine?.
I raised a perlbug (I can't find the ticket number off hand). The response I got (nearly a year later:) was that it was, at best, a documentation bug, and not something that needed to be fixed. I disagreed quite strongly with this.
I don't have a problem with the two versions doing something different if it was clearly documented, then you could make your choice of which form to use dependant upon which result fits your needs.
My concern was more that the result of the lvalue version produces a result that is neither one thing nor t'other.
$s='foobar'; print '4-arg: ', substr( $t=$s,1,4,$_) , ' 3-arg: ', substr($t=$s,1,4)=$_ for qw[ a ab abc abcd abcde abcdef ]; 4-arg: ooba 3-arg: ar 4-arg: ooba 3-arg: abr 4-arg: ooba 3-arg: abcr 4-arg: ooba 3-arg: abcd 4-arg: ooba 3-arg: abcd 4-arg: ooba 3-arg: abcd
As you can see, the 4-arg results are consistent, but the 3-arg version varies wildly.
No one is ever going to convince me that simply documenting this behaviour will make that logical, predicable or useful......still. "The problem space is a mess" :)
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re2: An Oddity of substr
by dragonchild (Archbishop) on Oct 10, 2003 at 15:33 UTC | |
by BrowserUk (Patriarch) on Oct 10, 2003 at 22:17 UTC | |
|
Re: Re: An Oddity of substr
by Zaxo (Archbishop) on Oct 10, 2003 at 07:30 UTC |