On Sun, 20 Jan 2002 07:27:41 +1100, Thomas wrote: > How do I write a function that uses the value of $_ in the calling > scope, so I can get the same behaviour as the many Kernel methods. While I don't have an answer to the specific question, it seems to me that talking about scope for $_ doesn't make sense, since it's a global. My first guess is that what happens when the parser sees the "def" for this method, it takes the CURRENT value for $_ and uses that as the default value for that parameter. Maybe you can do something like ... def fred(x = nil) if x.nil? x = $_ end end But, I'm just guessing here. The other comment I would make is that I think this may be a little confusing for users of the method, since it won't be obvious what's happening when they don't pass a value in. Personally, I think $_ is a perl-ism that should be allowed to die gracefully :-).