home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!cs.utexas.edu!sun-barr!male.EBay.Sun.COM!jethro.Corp.Sun.COM!eric.arnold@sun.com
- From: eric.arnold@sun.com (eric )
- Newsgroups: comp.lang.perl
- Subject: actually mnemonic special variable names
- Date: 25 Dec 1992 01:18:17 GMT
- Organization: Sun Microsystems, Inc.
- Lines: 61
- Distribution: world
- Message-ID: <1hdngpINN216@jethro.Corp.Sun.COM>
- Reply-To: eric.arnold@sun.com
- NNTP-Posting-Host: animus.corp.sun.com
-
- Has anyone already written something that aliases all those special
- variables (Camel book: "You can say one thing for them -- they're
- certainly concise."). For example, the first element of the default
- work variable is:
-
- $_[$[] (obChurchLady: "Well, [pause] isn't that *speeecialll*!")
- instead of:
- $WORK[$FIRST_ELEM]
- or $WORK[$F_EL]
-
- or another eg.: $OUTPUT_FIELD_SEPARATOR = "\t";
- or $OFS = "\t";
-
- In these cases, you might have the long and short alias
- for people with difference laconic leanings (or
- annoying alliterative abilities?).
-
- This requires something like:
- *WORK = *_;
- *F_EL = *[;
- *OUTPUT_FIELD_SEPARATOR = *<I can't remember>;
- *OFS = *<I can't remember>;
-
- or maybe writing a function call package which references the
- special variables directly.
-
- I was starting to do this myself, but it seemed like a lot of typing,
- and there might already be a set of aliases somewhere that people are
- using that are semi-standard (E.g. "OFS" for output field separator.)
-
- Also, would such an aliasing scheme work for the local special
- variables? I haven't tested many variables yet to see how they
- behave.
-
- There are two reasons that I want to do this: 1) because I can't
- remember the mnemonics suggested by the camel book that supposedly help
- one to associate punctuation and diacritical marks with Perl functions
- (they were fun to read, but...), and 2) because it's really hard to
- write semi-self-documenting/maintainable code with descriptive symbols
- when crucial operations hinge around symbols which look like $, or
- $_[$[] .
-
-
- -Eric
- Eric.Arnold@Sun.COM
-
-
- P.S. I won't even suggest, lest I get into trouble, that such aliases be
- added to Perl, either in "$NAME" form, or in another associative array,
- like "%ENV" or "%SIG", like $BUILTIN{OFS} = "\t"; or $SPEC{OFS} or
- $SV{OFS} or etc.
-
- This is one of the things about Perl which can't "be done more than one
- way". You have to use these variables, and so your script must take on
- their obfuscation (IMHO, they're the yuckiest part of Perl, the rest of
- which has been steadily growing on me) even if you are trying to make
- it look simple by keeping to C constructs, or using the
- conversational-style modifiers, or whatever. As far as I can tell,
- this is one area of Perl where you don't have your choice about economy
- of style (sans ubiquitous comments, of course).
-
-