Live data from Hacker News

Perl secret operators and constants

search.cpan.org

21–30 of 46 posts

Re: Perl secret operators and constants

#22
post #18

I have been using Perl since 1996, but I only use a handful of the secret operators. For me, the power with Perl is CPAN and the stability of Perl 5.

If you are working on a code base with others, it would be cruel to use some of these. However there are operators that could be beneficial to the advanced Perl users.

Re: Perl secret operators and constants

#23

I write perl everyday, I never use this stuff.

Numification is important if you output to another language, for instance, with JSON, where the other language will care about a string showing up where a number should have been.

List interpolation is occasionally necessary for syntax reasons, though I don't think of that as an operator, but the composition of its parts.

!! is for if you don't really love the loosey-goosey nature of Perl, and want to have a function that really, truly returns a boolean, and doesn't just return something that may or may not be a value that is either falsy or not. If you think in OO you may not want people coming to depend on the exact falsy value returned, which may expose internals. Generally I just go with the general Perl/scripting language approach, except when I know I'm leaking internals that I really, really don't want people to couple to.

The rest are mostly for show.

Re: Perl secret operators and constants

#24
post #8

It's articles like this that give Perl a bad reputation.

Mostly it was all the terrible code that got written in Perl by the first wave of non-programmers to start building web apps.

Then the bad reputation of PHP was the second wave of non-programmers building web apps?

Re: Perl secret operators and constants

#26
I wonder how many other languages have well-known secret operators?

I know of C's secret "limit" operator:

int x = 10; while (x --> 0) { printf("%i", x); }

prints 9876543210

Of course, in some ML dialects you can define your own opreators - such as (f |> g) to mean (g o f) which is actually very useful.

Re: Perl secret operators and constants

#28
post #8

It's articles like this that give Perl a bad reputation.

it's the existence of this that gives Perl a bad reputation. You can write Perl as though it were Python. In the Perl world that's called "baby talk"

https://www.google.com/search?q=perl+"baby+talk"

in the real world it's called clean, maintainable code.

Re: Perl secret operators and constants

#30

I wonder how many other languages have well-known secret operators? I know of C's secret "limit" operator: int x = 10; while (x --> 0) { printf("%i", x); } prints 9876543210 Of course, in some ML dialects you can define your own opreators - such as (f |> g) to mean (g o f) which is actually very useful.

That's not an operator, it's just precedence rules.

    while ((x--) > 0)
Post reply on HN