Interesting, but the title is misleading. They aren't operators, but rather mostly combinations of operators with potentially useful side effects.
Perl secret operators and constants
31–40 of 46 posts
Re: Perl secret operators and constants
#32I 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)
(Some of them aren't even collections of operators - }{ is a form of code injection, and the > thing has only one operator, applied to a string and a regex.)
Re: Perl secret operators and constants
#33Re: Perl secret operators and constants
#34if nothing else, most of these operators have immense nicknames. Now I just need an excuse to involve a flaming x-wing in my code... Operator Nickname Function ====================================================== 0+ Venus numification @{[ ]} Babycart list interpolation !! Bang bang boolean conversion }{ Eskimo greeting END block for one-liners ~~ Inchworm scalar ~- Inchworm on a stick high-precedence decrement -~ I…
Re: Perl secret operators and constants
#350+ - venus - numification: When you really need a scalar value to be represented as a number and not as a string. Useful when you're generating JSON and you need the types to be correct.
@{[ ]} - baby cart - list string interpolation: This is very useful when you need to interpolate arbitrary expressions inside a list. Useful when you're generating an SQL query, for example:
SELECT * FROM Office WHERE id IN (@{[ join(',', ('?') x @ids) ]})
!! - bang bang - boolean conversion: When you want to return a boolean value from a function, but you don't want to leak implementation details.,=> - winking fat comma - non-stringifying fat comma When you want to create a hash whose keys are constants.
Re: Perl secret operators and constants
#36It'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.
You can write Perl that looks like Python, or C, or whatever, but you're missing out on what makes Perl, Perl.
"baby talk" Perl is another name for being able to much with Perl, knowing very little of it. Also known as, "Getting your job done".
It's up to the individual to learn more about the language, which can be done gradually, much like a natural language.
"Clean, maintainable code" in Perl is actually known as, "Modern Perl" [0]
Re: Perl secret operators and constants
#37It'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
#38Earlier quoted context omitted.
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.
I think there's a difference between "baby talk" and using Perl as Perl. You can write Perl that looks like Python, or C, or whatever, but you're missing out on what makes Perl, Perl. "baby talk" Perl is another name for being able to much with Perl, knowing very little of it. Also known as, "Getting your job done". It's up to the individual to learn more about the language, which can be done gradually, much like a n…
This is particularly true because many syntax elements are literally impossible to Google. If you didn't happen to learn some idiom (syntax), you just can't deduce or discover what it does, unless a comment precedes it exactly listing the effect.
This is just the nature of Perl.
Re: Perl secret operators and constants
#39Interesting, but the title is misleading. They aren't operators, but rather mostly combinations of operators with potentially useful side effects.
Clearly you didn't read the DESCRIPTION section.
Re: Perl secret operators and constants
#40if nothing else, most of these operators have immense nicknames. Now I just need an excuse to involve a flaming x-wing in my code... Operator Nickname Function ====================================================== 0+ Venus numification @{[ ]} Babycart list interpolation !! Bang bang boolean conversion }{ Eskimo greeting END block for one-liners ~~ Inchworm scalar ~- Inchworm on a stick high-precedence decrement -~ I…
When I first learnt perl, twenty years ago, I loved it because it was full of clever devices and syntactic virtuosism. Now, I don't like it anymore exactly for the same reason. It's cool, but the wrong kind of cool.