From: Sam Roberts Date: 2006-06-23T00:57:16+09:00 Subject: Re: bug in $. ? Quoting wybo@servalys.nl, on Thu, Jun 22, 2006 at 06:46:48PM +0900: > Pit Capitain wrote: > > >DATA does indeed "point to" the input file, right after the __END__. You > >can verify this for example by calling DATA.rewind. After that, you can > >read the text before the __END__. > > Sure, but that is part of the bug, in my opinion. After DATA.rewind I You mentioned perl before, note that this is identical to perl, you can read before the __END__. > want to see the first line of the DATA section again. If I want to see > the program source, I can use $0 Not necessarily. > >>2. As is, $. is useless when reading from DATA > > > >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 > 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 you would want $. to refer to the real line in the file, more easy to find than to cound offsets. Sam