On Sun, 11 Mar 2001, Mathieu Bouchard wrote: > In pickaxe book, p.371, it is said that ~ a_string is equivalent to $_ =~ > a_string. Well, I tried to define MetaRuby's StringMixin#~ like that, Clarifying things: Pickaxe book is correct when saying ~str is like $_=~str, but that assumes inline substitution of source code. when writing def ~; $_ =~ self; end The $_ is our own $_ variable. $_ is *not* a global, nor a thread-local... I think it may be a file-local, but I haven't thoroughly examined that. Therefore, I must get the caller's $_. Currently, the simplest way I have found to define String#~ is (amended version): def ~ r,w = IO.pipe if not fork then set_trace_func(proc{|*a| w.puts(eval("$_", a[4]).inspect) exit! }) else Process.wait eval(r.readline) =~ self.to_str end end I tried using set_trace_func alone but I have to return a value before I get to reach the caller's binding. I tried trace_var but there is no single global $_ so trace_var does not get notified when it "changes". What should I do? matju