Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Bug with $` in s///; in 4.000,4.003

14 views
Skip to first unread message

ckc...@athena.mit.edu

unread,
Apr 20, 1991, 3:37:01 PM4/20/91
to

A problem occurs when trying to replace tabs with spaces using the
invocation:

while (<>) {
1 while s/\t+/' 'x (length($&) * 8 - length($`) % 8)/e;
print;
}

(taken from the Gospel According to lwall, Chapter 3, pg. 105, footnote 31)

When I run it in 3.044, it works fine, but when I try it in 4.000 or
4.003, it acts as if length($`) is 0; i.e., as if $` is not bring set.

I have not seen anything in the documentation which indictates that this
behavior change is intentional. Am I missing something?

-Calvin

INTERNET ckc...@mit.edu
UUCP ...!mit-eddie!mit-athena!ckclark
BITNET Use a ouija board.

Larry Wall

unread,
Apr 22, 1991, 1:54:38 PM4/22/91
to
In article <1991Apr20.1...@uvaarpa.Virginia.EDU> ckc...@athena.mit.edu writes:
: A problem occurs when trying to replace tabs with spaces using the

: invocation:
:
: while (<>) {
: 1 while s/\t+/' 'x (length($&) * 8 - length($`) % 8)/e;
: print;
: }
:
: (taken from the Gospel According to lwall, Chapter 3, pg. 105, footnote 31)
:
: When I run it in 3.044, it works fine, but when I try it in 4.000 or
: 4.003, it acts as if length($`) is 0; i.e., as if $` is not bring set.
:
: I have not seen anything in the documentation which indictates that this
: behavior change is intentional. Am I missing something?

No, you're right. There was a bug in 3.044 having to do with recursion
if the RHS called the subroutine containing the current substitution. In
fixing this, I managed to "unfix" $`. It will be fixed in patch 4.

Sorry. My testing organization is either too small, or too large, depending
on how you look at it. :-)

Larry

0 new messages