From: "Bartosz Dziewoński" Date: 2011-08-29T22:17:09+09:00 Subject: Re: String#split resets regex captures variables (Ruby 1.8.7) 2011/8/29 Josh Cheek : > 2011/8/29 Bartosz Dziewoński >> I think it makes sense for $1, $2 etc to change any time a regex match >> is performed anywhere in Ruby, it might be even kind of useful in some >> perverse scenarios. That said, you shouldn't use these if you can, >> it's a Perl relic (but I admit, sometimes it's the easiest way). >> > I don't, that means that if you call some method, then it can implicitly and > unintentionally change variables you've set, and the only way to know it is > to go digging through source code. You could empirically experiment with it, > but say the regex was conditionally evaluated, then you'd not know it was > used unless conditions were right, meaning it might not pop up until you > were in production. That's precisely why you shouldn't use them in anything except for scripts written in 20 minutes. 2011/8/29 Robert Klemme : > And actually the situation is much more friendly: $1 etc. are local to > stack frame... > > ... and local to thread: > Fun, fun, fun. Semi-local global variables. I had no idea it's that crazy. -- Matma Rex