Perl secret operators and constants
search.cpan.org
search.cpan.org
But it's a really deep language, and not necessarily in ways that academic language designers want it to be. Perl always feels more like having a conversation with your computer than programming it. These kinds of operators are like having a whole host of additional highbrow verbs you can use in conversation if you want.
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
-~ Inchworm on a stick high-precedence increment
-+- Space station high-precedence numification
=( )= Goatse scalar / list context
=< >=~ Flaming X-Wing match input, assign captures
~~<> Kite a single line of input
<<m=~m>> m ; Ornate double-bladed sword multiline comment
-=! -=!! Flathead conditional decrement
+=! +=!! Phillips conditional increment
x=! x=!! Pozidriv conditional reset to ''
*=! *=!! Torx conditional reset to 0
,=> Winking fat comma non-stringifying fat comma
()x!! Enterprise boolean list squash
0+!! Key to the truth numeric boolean conversion
~~!! Serpent of truth numeric boolean conversion
||() Abbott and Costello remove false scalar from list
//() Leaning Abbott and Costello remove undef from list+"123234" +"1e29" +"abc" // -> NaN
print +(1 + 2) * 3;
print ((1 + 2) * 3);
print (1 + 2) * 3;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.
Would this be valid?
$x +=!! =<>=~ s/readable-code//g;
Perl, as confusing as it can seem, has fairly consistent rules that it follows. Learning those and keeping them in mind will generally let you intuit how something is expected to work.
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]
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.
I would encourage you to check out some of the more recent tools and books on Perl that help greatly in making code readable and maintainable, like the Modern Perl book, the Perl Best Practices book or things like Moose - or even if I dare say, Perl 6.
The Perl Community has come a long way since when I started in 1999, that's for sure. So has the entire Industry, to be quite honest.
Learn the language you are writing code in, and use idiomatic code for that language.
0+ - 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.
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.
while ((x--) > 0)(Some of them aren't even collections of operators - }{ is a form of code injection, and the <<m=~m>> thing has only one operator, applied to a string and a regex.)