From: Pit Capitain Date: 2006-06-22T19:47:07+09:00 Subject: Re: bug in $. ? Wybo Dekker schrieb: > Sure, but that is part of the bug, in my opinion. After DATA.rewind I > want to see the first line of the DATA section again. If I want to see > the program source, I can use $0 Makes sense. According to Matz's reply, he sees a bug somewhere, too. Maybe he just wants to fix writing to $. as Guy has shown, maybe he wants to restrict DATA to the section after the __END__, as you had expected. If you search the ruby-talk archives, you'll find ways to reset DATA to the position after the __END__, if you need this behaviour. BTW: you can get to the current file via __FILE__, not $0. >> Why do you need $. to start from 0 when reading from DATA? What is it >> that you're trying to do? > > In this case, I wanted to skip the first line: next if $.==1 Admitted, to do something with the n-th line of the DATA section, you have to remember the line number offset before processing the DATA section. Not hard to do, but not as pretty as it could be. > But it can, for example, also be used to errors in the DATA section: > raise("illegal key in line #{$.} of the DATA section") In this case I'd prefer the current behaviour. My editors know nothing about the DATA section, so its easier to jump to line n of the current file instead of line n of the DATA section. We'll see what Matz comes up with. Regards, Pit