is it possible to override a 'read only' environmental variable like $" ?



Hi guys/gals,
I am trying to write a method to give the full paths of all files
loaded into a program when a require statement is executed.
I would like to be able to get the same result each time a "require
'file'" statement is executed. To do so, I need to get the $"
back to the state it was in prior to the require command being
executed. But alas it is read only and does not allow me to redefine
it.
Anyone know how to override a read only setting or circumvent this
somehow.
Thanks is advance,
Tim
See the code below:

def catch_new_paths(file_to_require)
old = $".dup
require(file_to_require)
new = $".dup
after = new - old
after.each{|file| $:.each{|path| puts path + "/" + file if
File.exists?(path + "/" + file)}}
#at this point I would like to convert the $" variable back to its
state before the require statement was run with
#$" = old
#but doing so results in
# -:7:in `catch_new_paths': $" is a read-only variable (NameError)
end

catch_new_paths("base64")
# >> /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/
ruby/1.8/universal-darwin9.0/nkf.bundle
# >> /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/
ruby/1.8/kconv.rb
# >> /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/
ruby/1.8/base64.rb
.



Relevant Pages

  • Re: redefine and override
    ... >I would like to know what is the difference between redefine and override. ... >I'm reading in a book and here it says a virtual function is one that a ... >do not want a derived class to redefine a particular member function, ...
    (alt.comp.lang.learn.c-cpp)
  • Re: Poor VB Programming
    ... Yes that's true but most won't allow you to do it by accident. ... you want to replace a runtime function you must omit the lib in which it ... it that it will allow you to redefine ... overridable, there are rules, it'd be pretty difficult to override something ...
    (microsoft.public.sqlserver.programming)
  • Re: Poor VB Programming
    ... Yes that's true but most won't allow you to do it by accident. ... you want to replace a runtime function you must omit the lib in which it ... it that it will allow you to redefine ... overridable, there are rules, it'd be pretty difficult to override something ...
    (microsoft.public.vb.database)
  • Re: Poor VB Programming
    ... Yes that's true but most won't allow you to do it by accident. ... you want to replace a runtime function you must omit the lib in which it ... it that it will allow you to redefine ... overridable, there are rules, it'd be pretty difficult to override something ...
    (microsoft.public.vb.database.ado)
  • Re: Read #<>
    ... need to read the damn file in somehow, ignoring the #'s!" ... note that you can redefine #< like: ... if not, manual adjustments may follow. ...
    (comp.lang.lisp)