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


-- 
Wybo