Moin!

This code:

   class String
     alias :old_gsub :gsub
     def gsub(*args, &block)
       old_gsub(*args, &block)
     end
   end

   "hello world".gsub(/(\w+)/) { print $1; $1 }; print "\n"

produces this output for me:

   nilnil

(I'm using ruby 1.8.0 (2003-08-04) [i386-mswin32] and I'm told that it 
does the same in the 1.8.0 final, 1.7.3 and 1.6.8 on Linux.)

Is this behaviour by design or is this a bug? If it's not a bug: Why 
is $1 changed to nil in this case?

(This behaviour is causing an annoying bug in my new Ruby 
implementation of Perl 6's Junctions and thus effectively replacing 
irb's prompt with "()::>")

Thanks for any answers and effort to clarify this issue!

Regards,
Florian Gross