5 ms·
As someone with zero Perl experience...is this a joke? People naming variables with literal control characters?!
by bkeroack 12y ago
As someone with zero Perl experience...is this a joke? People naming variables with literal control characters?!
- VLM 12y agoYes. Its a running joke WRT general global variables, and they all have a single character synonym. And once you use up the preferred letters, well, stranger things are used. a C programmer who understands command line argument lists would not even remotely be surprised at the contents of the general variable $0. Its probably more "civilized" to call it $PROGRAM_NAME in your code, but whatever. I don't think this is controversial to alias $PROGRAM_NAME to $0 for anyone civilized aka some minimal C experience. Perl tends to be consistent. In a similar style, if you insist on implementing a global general variable like $PERL_VERSION which contains a string of pretty much what it sounds like it contains, to keep things consistent all general vars also have a single character synonym, so welcome to $"control-V" In the "real world" you can write something stupid enough to get yourself fired. This kind of activity probably qualifies unless you have an excellent excuse. Perhaps if you have a complicated if-then statement with numerous clauses and using one individual weird, yet short, variable name allows a debugging programmer to keep the whole control flow in their head instead of scrolling the mess off the screen, then, maybe, its a win. But I wouldn't make a habit of it. Given that you can pretty much transparently "upgrade" or "downgrade" the code with a simple search and replace its not a major crisis. A lot of people use Perl::Critic as a Perl "lint" and a lot of those users put large amounts of the perlvars file in the Variables::ProhibitEvilVariables test although the Perl::Critic authors don't by default include them, which many people consider a bug in Perl::Critic but whatever.
- gpvos 12y ago> Perl tends to be consistent. Well, for a certain kind of consistency, yes. From the perlfunc manpage, about the return values of Perl's operators and functions in scalar versus list context: In general, they do what you want, unless you want consistency.
- Mithaldu 12y ago> Its probably more "civilized" to call it $PROGRAM_NAME in your code, but whatever. I don't think this is controversial to alias $PROGRAM_NAME to $0 for anyone civilized aka some minimal C experience. There is `use English;` for that. :)
- pflanze 12y ago$0 (along with $1 etc.) is used in shells, at least bash [and original sh?]. I think Perl just borrowed those, like $ prefixes to variables or not offering explicit subroutine arguments, from the traditional unix shell(s).
- __david__ 12y agoAnd $$, and $?. Even Perl's $#x syntax to get the max index of @x seems to come from shell's $#. Also interesting, Ruby copied most of Perl's crazy variables [1]. [1] http://www.rubyist.net/~slagell/ruby/globalvars.html http://www.rubyist.net/~slagell/ruby/globalvars.html
- Mithaldu 12y agoRuby's goal was to be Perl, but better.
- __david__ 12y agoThen they probably shouldn't have copied the crazy obscure variable stuff ;-) (I say that as a Perl and Ruby fan)
- nikatwork 12y agoMatz admits that he might have stolen too much from Perl and got some "whale guts" over his shoes - but only a little. From the obligatory Yegge rant: https://sites.google.com/site/steveyegge2/tour-de-babel https://sites.google.com/site/steveyegge2/tour-de-babel
- Mithaldu 12y agoLinking yegge is quite pointless, since even in that little screed he demonstrates amply how he doesn't even know the basics of Perl and in fact knows so little that his judgement isn't worth the bytes that store it.
- 12y ago