From: Mauricio Fernandez Date: 2006-06-19T21:48:36+09:00 Subject: Re: DATA and $. On Mon, Jun 19, 2006 at 09:28:40PM +0900, Wybo Dekker wrote: > Is it correct that the first line read from DATA has not $. == 1 ? > (This differs from Perl) > > #!/usr/local/bin/ruby > DATA.each { |d| puts "lineno: #{$.} has: #{d}" } > __END__ > 1 > 2 > 3 > > => > lineno: 4 has: 1 > lineno: 5 has: 2 > lineno: 6 has: 3 You could hardly reconcile $. == 1 with this: batsman@tux-chan:~/mess/current$ cat data.rb DATA.rewind DATA.each{|l| puts "lineno: #{$.} -> #{l}" } __END__ foo batsman@tux-chan:~/mess/current$ ruby data.rb lineno: 1 -> DATA.rewind lineno: 2 -> DATA.each{|l| puts "lineno: #{$.} -> #{l}" } lineno: 3 -> __END__ lineno: 4 -> foo -- Mauricio Fernandez - http://eigenclass.org - singular Ruby