On 12 Jun 2000, Dave Thomas wrote: > Well, you _could_ implement Perl's 'local' facility for Ruby globals: > > > def local(*syms) > save = {} > syms.each { |aSym| save[aSym] = (eval "#{aSym}") } > begin > yield > ensure > save.each { |aSym, aVal| eval "#{aSym} = aVal" } > end > end > [...] This looks good to me. > > This is pretty tacky code - the 'local' method should check that it is > only passed true globals, [... Re-using an existing local variable and leaving it unchanged is not a problem, is it? Not sure why you need to only include true globals. I don't thingk you'd have the same problems like Perl's local() vs my() in nested calls either. > ...] and should reject $_ and $!. That's left as I agree with that. > an exercise to the reader (as we say) ;-) > > > Dave > > Hugh hgs / dmu.ac.uk