From: "Mauricio Fernández" Date: 2004-03-20T07:13:53+09:00 Subject: require resets $! to nil. Bug or feature? batsman@tux-chan:/tmp$ cat excep2.rb begin raise "foo" rescue Exception puts "$! is #{$!.inspect}" require 'digest/md5' puts "$! is #{$!.inspect}" end batsman@tux-chan:/tmp$ ruby excep2.rb $! is # $! is nil I was bitten by this when doing something like def somemeth require 'digest/md5' ... end def foo ... begin ... rescue Exception somemeth raise # I expected this to re-raise the exception, not to # create a new one with an empty message end ... end Note that rescue Exception => e somemeth raise e end is not a desirable solution because the backtrace info will be modified. For now I will move the requires but I'd like to know if require's behaviour w.r.t. $! is deliberate, and if so, the rationale. I've scanned the first ~ 80000 messages of ruby-talk and couldn't find any reference to this issue. -- Running Debian GNU/Linux Sid (unstable) batsman dot geo at yahoo dot com 'Ooohh.. "FreeBSD is faster over loopback, when compared to Linux over the wire". Film at 11.' -- Linus Torvalds