Now I am old and joyless and I want the code I write for work to be boring and unsurprising.
But sometimes one can still want to write poetry.
Subsequently I've written code in almost every popular programming language and I will frequently go years between languages but even so I have very little trouble picking them back up. Even C++. But not Perl. It's just so weird with so many idiosyncrasies that I just can't remember it.
I learned Perl after trying C; and after struggling with `scanf` (not even getting to tokenization), the ease and speed of `while (<>) { @A = split;` for text-handling made it easy to fall in love. This (in the mid 90s, before Java, JavaScript, and C++ TR1) was also my first contact with associative arrays.
I was also drawn to the style of the Camel Book.
More than most other languages, Perl encouraged one-liners. When I later read PG's "Succinctness is power" essay, I thought of Perl.
Associative array is just a fancy term for map / dictionary. C++ has always had one of those, even before TR1: std::map (which is a tree under the hood). It does have the extra requirement that your key be ordered, which isn't part of the core definition of associate array[1]. But usually it's not a problem even if you don't actually need the ordering.
As I think you're implying, TR1 / C++11 added std::unordered_map, which is a hash table and doesn't need keys to be ordered (just hashable).
[1] It isn't part of the core definition of "map" either, which despite C++'s usage just means the same thing as dictionary / associative array. A lot of those early STL containers are confusingly named: e.g., in general, "list" just means some ordered sequence of elements, so it covers static arrays, dynamic arrays, and linked lists, but C++ uses this term for linked lists, probably the least likely understood meaning. It use of the term "vector" for contiguous dynamic arrays is very odd. But I'm now way off topic...
I don't believe you.
When I started out as a sysadmin it was all shell and glue and different syntax on the 8 different flavours of *NIX I worked on between '94 and '97, then I found Perl suddenly you could actually build things that felt "real". It took me straight into web application development by '98, and I'm not sure I would have stayed in this field had it not existed (I was also working in neuro-diagnostics at the time and might have stayed there).
I saw some really elegant stuff written in Perl.
I also saw some absolutely unhinged, impossible-to-maintain garbage.
Unfortunately I had a different experience with the Ruby community, so I eventually switched to Python along with apparently everybody else.
This isn't a special operator. This is just how "not" (!) works. In basically every language: C, C++, Javascript, Perl, etc., ! is the "not" operator so !12 gives you false (12 is truthy), and !!12 (not false) gives you true.
It's the same in languages that use different operators for "not". In python, the "not" operator is just the word not, and can write "not not 12" to get True. They didn't implement a special "not not" operator, anymore than Perl implemented a "!!" operator. They just implemented the basic ! / "not" operator.
Any non-zero value becomes `1`, and zero remains `0`. This is commonly used for boolean normalization when the original expression yields a bitmask or arbitrary integer.
While the same result can be written as `(x != 0)`, the `!!x` idiom is concise, widely used in low-level C code, guarantees a result of exactly `0` or `1`, and works well in macros and constant expressions.
Confusingly (to some) they are integers and while 0 represents FALSE, any non 0 value represents TRUE.
It's pedantic, apologies, but that is why the GP refers to "convert to strict boolean"
The "Venus" operator is a good example: it's the '+' addition operator! You just add zero to a value that's coercible into a number.
The Eskimo operators are also interesting: similar to a SQL injection attack, you use a close brace and an open brace to stop and start a new code block from within a string that's sent to the interpreter. Perl didn't invent open and close braces: hence the verb "discover" rather than "implement".
The whole page is a bit of a lark, and a good example of why some of us don't enjoy Perl!
But looks like Perl's implementation is more limited compared to other languages:
% perl -e 'print ~-(0), "\n"'
18446744073709551615
% ruby -e 'print ~-(0), "\n"'
-1
https://metacpan.org/dist/perlsecret/view/lib/perlsecret.pod... perl -Minteger -E 'say ~-0'
and it should work as expected.if ($text =~ /error/) { print "Found error\n"; }
if ($text !~ /error/) { print "No error found\n"; }
It's just fun and fast to slice and dice text this way.
tasty_freeze•3w ago