hi, i was interested if perl is still relevant in this day and age. Perl has been on the decline for a very long time now. Perl 6 (now named 'raku) not being backwards compatible with perl 5 code made the already small perl community even smaller by splitting it in half. A good example is lisp with it’s thousands of different dialects.
Is it still worth using or is it bound to legacy software forever? Like cobol.
The worst one I stumbled across while reading a colleagues script was the three separate namespaces for symbols of type scalar, array, and hash.
You mean the fact that you can have a hash called %foo, an array called @foo and a scalar called $foo all at the same time? I agree that’s a weird choice and there’s potential for insanity there, but it’s pretty easy to just not do that…
20+ years of Perl experience and while Perl has a load of idiosyncrasies that make it harder to work with than other languages, I don’t think that particular one has ever caused a significant problem.
Yes, exactly. Those definitions aren’t clashing, so they must have separate namespaces.
I wouldn’t do that either, but my colleage apparently did. So far I’m having a harder time reading perl than writing it.
The way it works is that there’s a symbol table entry for “foo” which has a slot for a hash, scalar, array, glob, etc.
That leads to some super weird behaviour like, for example, if I declare a scalar, hash and array as “x”:
You can access them all independently as you’re aware:
But what’s really going to bake your noodle is I can assign the “x” symbol to something else like this:
…and then the same thing works with z:
Oneliner if you want to try it:
Congratulations! You now know more about one of Perl’s really weird internals than I’d wager most Perl programmers (I have literally never used any of the above for anything actually productive!)