From: Heesob Park Date: 2009-06-12T16:45:51+09:00 Subject: How to set $_ in a method? Hi all, I like to set caller's $_ variable in a method, but it did't work for me. Consider this: def foo puts "$_ = #{$_.inspect} enter foo" $_ = 'def' puts "$_ = #{$_.inspect} exit foo" end $_ = 'abc' puts "$_ = #{$_.inspect} before foo" foo puts "$_ = #{$_.inspect} after foo" The result is: $_ = "abc" before foo $_ = nil enter foo $_ = "def" exit foo $_ = "abc" after foo I noticed $_ is is local to the current scope. Is it impossible to set the caller's $_ variable in a method without using binding and eval? Thanks, Park Heesob