Hi all,
I'm sure we've all wished for a concatenation operator that would prepend a string to a string in the same way the .= operator appends.
So why isn't there one?
It's silly that you can write:
But not:$foo .= 'bar';
and instead have to do:$baz =. 'qux';
$baz = 'qux' . $baz;
Today I got to wondering if I had missed that such an operator had been introduced in some recent Perl version so I ran the code, and to my surprise Perl said:
Now, if Perl knows that this particular syntax error is a "reversed .= operator", and not, say, "some new operator I didn't know about" - i.e. the syntax is not in use for anything else - then why isn't it implemented?Reversed .= operator at -e line 5. syntax error at -e line 5, near "=."
Can any guts gurus shed any light?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Reversed .= operator
by LanX (Saint) on Apr 29, 2016 at 16:54 UTC | |
|
Re: Reversed .= operator
by choroba (Cardinal) on Apr 29, 2016 at 21:40 UTC | |
by 1nickt (Canon) on Apr 29, 2016 at 22:08 UTC | |
by choroba (Cardinal) on Apr 29, 2016 at 22:25 UTC | |
by pryrt (Abbot) on Apr 29, 2016 at 22:38 UTC | |
by choroba (Cardinal) on Apr 29, 2016 at 22:44 UTC | |
| |
|
Re: Reversed .= operator
by Laurent_R (Canon) on Apr 30, 2016 at 09:42 UTC | |
by 1nickt (Canon) on Apr 30, 2016 at 15:50 UTC | |
by Laurent_R (Canon) on Apr 30, 2016 at 16:16 UTC | |
by BrowserUk (Patriarch) on Apr 30, 2016 at 19:27 UTC | |
by Laurent_R (Canon) on Apr 30, 2016 at 21:24 UTC | |
by raiph (Deacon) on May 03, 2016 at 06:26 UTC | |
by Laurent_R (Canon) on May 03, 2016 at 20:58 UTC | |
|
Re: Reversed .= operator
by karlgoethebier (Abbot) on May 03, 2016 at 07:38 UTC |