From: jeremy@... (Jeremy Henty) Date: 2001-03-30T06:40:05+09:00 Subject: [ruby-talk:13341] Why is $_ local to the current scope? This bit me when I wrote something like: def barf() print "Yikes, can't cope with #{$_} at line #{$.}\n" end If I barf at some random point then $. brings up (sorry!) the line number but $_ is empty. I have to pass $_ explicitly to barf (ok, I *really* regret this terminology now!). Why does one work and not the other? In the chapter "The Ruby Language" of "Programming Ruby", $_ is the only variable under the heading "Input/Output Variables" that has local scope, so it seems a bit anomalous. Or am I looking at this the wrong way? Can someone explain the Ruby way here? Also, I'm surprised that 'ARGF.each do ...' sets $. but not $_. Again I don't see the reason for this. Enlightenment will be welcomed! Cheers, Jeremy Henty