|Perl: the Markov chain saw|
Re^2: Wrong idioms (digression)by Intrepid (Deacon)
|on Mar 31, 2013 at 19:05 UTC||Need Help??|
IMHO, probably so! And FWIW, Perl is not the only programming language in which some obvious problems pertaining to "truth" might need to be thought about carefully. We've discussed Bash, and here's another one: VimL or Vim script (AKA “ex”).
In VimL it is complicated where Bash makes it easy. To test for both defined-ness and non-null-ness / non-zero-ness, there are some hoops to jump through.
Vim will complain if we try to do anything with a variable identifier that has not been defined yet. So I found myself having to write a function that does this, since I was rewriting the same code so often in my .vimrc:
First a test must be run to determine if the referenced variable even exists. Then if it does we need to "extract" the reference (ok, "dereference" if you like). Then we can finally test the data actually in the variable, using "length" (but in VimL we spell it strlen() as if we were C programmers), and also accounting for a numeric value by following that test with a numerical comparison. The end result is that we've worked out whether this variable is approximately "true" or "false" in a Perlish sense.
This is not a Perl topic ... but improvements, critiques welcomed (I know there are Vimmers hiding in plain sight around here).
Oh, and BTW: anyone who went Ewwww when they perceived the design principles of VimL revealed in that code: you wouldn't be the first ;-)Intrepid Mar 31, 2013 at 18:26 UTC
Examine what is said, not who speaks.
Love the truth but pardon error.
Silence betokens consent.
In the absence of evidence, opinion is indistinguishable from prejudice.