"there's more than one way to do it" is more about allowing a more comfortable style for some tasks, or express some concepts in a better way.
So for instance, Perl has a completely ordinary if statement:
if ($foo) {
say "Foo is enabled";
}
However, it also allows doing this:
say "Processing file $filename" if ($debug);
Used judiciously, this can make code better because you avoid breaking up the flow with a bunch of braces. It's also easy to tack on to the end of an existing statement.
The downside of course is the lack of predictability, such features can make code more confusing to read rather than clearer if abused. This kind of thing is just syntactic sugar and not inherently a bad thing. The issues that come up are mostly a result of some people trying to be too clever.
Which is exactly the problem. Yes, some people will use it judiciously.
Other people will just use it wherever possible. Yet others will mix it with the alternative style willy-nilly. Some won't use it at all. And as you so correctly point out, some people will try to be too clever with it.
The result is the exact opposite of what was originally intended by syntactic sugar: Instead of making code easier to read, it becomes harder.
The only way to , at least partially, prevent that, is for languages to be restrictive in their syntax. Yes, that may be more verbose at times. But I consider that a small price to pay for consistency.
The problem with perl is that the language is so dense and complex that everything means something (and is very context sensitive) so it's very hard to know what a specific piece of code means and if it was intended that way by the author.
Perl was intentionally (designed by linguist) to be like a "human" language, with all the small benefits and large problems that entails.
So for instance, Perl has a completely ordinary if statement:
However, it also allows doing this: Used judiciously, this can make code better because you avoid breaking up the flow with a bunch of braces. It's also easy to tack on to the end of an existing statement.The downside of course is the lack of predictability, such features can make code more confusing to read rather than clearer if abused. This kind of thing is just syntactic sugar and not inherently a bad thing. The issues that come up are mostly a result of some people trying to be too clever.