worley@compass.com (Dale Worley) (02/09/91)
Beware when using the $^ variable to always follow it with a whitespace character! Otherwise the next character will be eaten and (probably) the variable misinterpreted. The culprint is the following two lines from scanreg() in toke.c: if (*d == '^' && !isspace(*s)) *d = *s++ & 31; It appears that these are to allow constructions like: $^T means "the variable whose name is control-T". Since there are no such variables anymore, these lines should probably be removed. (It would not be simple to restrict the third character of the construction to characters that can be legitimately controlized (letters, @, [, \, ], _, ^), because '^' is also an operator, leading to $^^ meaning either "the variable control-^" and "the variable $^ followed by the operator ^". Dale Worley Compass, Inc. worley@compass.com -- I try to make everyone's day a little more surreal.
merlyn@iwarp.intel.com (Randal L. Schwartz) (02/09/91)
In article <1991Feb8.174228.678@uvaarpa.Virginia.EDU>, worley@compass (Dale Worley) writes: | It appears that these are to allow constructions like: $^T means "the | variable whose name is control-T". Since there are no such variables | anymore, these lines should probably be removed. No such variables anymore? C'mon, I know 3.041 isn't *that* old. When we got -C, -A, and -M, we got $^T. OK, so it didn't end up in the manpage (it went immediately into The Book, though :-), but it's still there. | (It would not be | simple to restrict the third character of the construction to | characters that can be legitimately controlized (letters, @, [, \, ], | _, ^), because '^' is also an operator, leading to $^^ meaning either | "the variable control-^" and "the variable $^ followed by the operator | ^". Agreed. The syntax is messy, but it's there. And we'll probably be stuck with it for quite a while, now that $^T is in the mix, and we're running out of other single chars. Did you know you can use the control characters literally too? Watch this (yes, the newline is part of the code!): $^J = "Just another Perl hacker,"; print $ -- /=Randal L. Schwartz, Stonehenge Consulting Services (503)777-0095 ==========\ | on contract to Intel's iWarp project, Beaverton, Oregon, USA, Sol III | | merlyn@iwarp.intel.com ...!any-MX-mailer-like-uunet!iwarp.intel.com!merlyn | \=Cute Quote: "Intel: putting the 'backward' in 'backward compatible'..."====/
rbj@uunet.UU.NET (Root Boy Jim) (02/09/91)
In article <1991Feb8.174228.678@uvaarpa.Virginia.EDU> worley@compass.com writes: >Beware when using the $^ variable to always follow it with whitespace. Good Point! >It appears that these are to allow constructions like: $^T means "the >variable whose name is control-T". Since there are no such variables >anymore, these lines should probably be removed. What do you mean "no such anymore"? $^T == $^t == $<ctrl-T> is time. I don't know how long it's been there, and whether or not it once was, then wasn't. But with $^t it certainly is now! I wonder if we can expect $^h to be our hostname, etc. On a PDP-11, I would guess that $^f would be the switch register :-) -- Root Boy Jim Cottrell <rbj@uunet.uu.net> I got a head full of ideas They're driving me insane
worley@compass.com (Dale Worley) (02/13/91)
Here's a patch to make $^ behave somewhat more civilly. When it is installed, $^ only absorbs the next character if it is a letter or one of @[\]^_. That should fix most of the strange behavior. This still leaves the ambiguity in $^^ (it is interpreted as "variable control-^), but that can be lived with. *** toke.c.orig Tue Feb 12 11:43:22 1991 --- toke.c Tue Feb 12 11:46:09 1991 *************** *** 1466,1472 **** else d[1] = '\0'; } ! if (*d == '^' && !isspace(*s)) *d = *s++ & 31; return s; } --- 1466,1473 ---- else d[1] = '\0'; } ! if (*d == '^' && ! (('@' <= *s && *s <= '_') || ('a' <= *s && *s <= 'z'))) *d = *s++ & 31; return s; } Root Boy Jim writes: On a PDP-11, I would guess that $^f would be the switch register. TECO fiend! But since Perl claims Basic-Plus as one of its (illegitimate) parents, it sounds reasonable. I remember that the only peek that didn't require privileges was PEEK(-56), which returned the switch register... Dale Worley Compass, Inc. worley@compass.com -- The United States has entered an anti-intellectual phase in its history, perhaps most clearly seen in our virtually thought-free political life. -- David Baltimore
lwall@jpl-devvax.JPL.NASA.GOV (Larry Wall) (02/13/91)
In article <1991Feb12.180057.20540@uvaarpa.Virginia.EDU> worley@compass.com writes: : Here's a patch to make $^ behave somewhat more civilly. When it is : installed, $^ only absorbs the next character if it is a letter or one : of @[\]^_. That should fix most of the strange behavior. This still : leaves the ambiguity in $^^ (it is interpreted as "variable : control-^), but that can be lived with. : : *** toke.c.orig Tue Feb 12 11:43:22 1991 : --- toke.c Tue Feb 12 11:46:09 1991 : *************** : *** 1466,1472 **** : else : d[1] = '\0'; : } : ! if (*d == '^' && !isspace(*s)) : *d = *s++ & 31; : return s; : } : --- 1466,1473 ---- : else : d[1] = '\0'; : } : ! if (*d == '^' && : ! (('@' <= *s && *s <= '_') || ('a' <= *s && *s <= 'z'))) : *d = *s++ & 31; : return s; : } Beware. 4.0 will only allow A-Z and [\]^_?. Notice no @ or lower case. I'd have to rewrite the symbol table code to allow an identifier containing a null, and I don't fancy doing that right now. It's restricted to upper case so's I can just say *s ^ 64, me being lazy and all. The lines read: if (*d == '^' && (isupper(*s) || index("[\\]^_?",*s))) *d = *s++ ^ 64; : Root Boy Jim writes: : On a PDP-11, I would guess that $^f would be the switch register. : : TECO fiend! But since Perl claims Basic-Plus as one of its : (illegitimate) parents, it sounds reasonable. I remember that the : only peek that didn't require privileges was PEEK(-56), which returned : the switch register... Yep. Did you ever try writing a run-time system with no documentation? That was fun. Disassembling the operating system helped, a little. "Who stomped on my FIRQB?!!??!!" Larry