DATA and $

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

On Mon, Jun 19, 2006 at 09:28:40PM +0900, Wybo D. wrote:

=>
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