From: "nobu (Nobuyoshi Nakada)" Date: 2012-07-12T12:39:38+09:00 Subject: [ruby-core:46344] [ruby-trunk - Bug #6723][Assigned] Global variable scoping problem. Issue #6723 has been updated by nobu (Nobuyoshi Nakada). Category changed from core to DOC Status changed from Open to Assigned Assignee changed from matz (Yukihiro Matsumoto) to drbrain (Eric Hodel) ruby -v changed from ruby 1.9.3p194 to - ---------------------------------------- Bug #6723: Global variable scoping problem. https://bugs.ruby-lang.org/issues/6723#change-27961 Author: iblue (Markus Fenske) Status: Assigned Priority: Normal Assignee: drbrain (Eric Hodel) Category: DOC Target version: 2.0.0 ruby -v: - This issue exists from 1.8 to ruby-head. See the following example: def foobar "Foobar".match(/^(\w*)/) puts $1.inspect end foobar puts $1.inspect puts global_variables.inspect This demonstrates that $1 does not behave like a global variable. However it's listed by Kernel.global_variables as a global variable. And it's named like a global variable. This leads to some confusion sometimes. See for example http://stackoverflow.com/q/11441782/773690 It may not be a good idea to fix this inconsistent naming, because it may break severaly things. However the fact that $1 and friends are not global variables should be clearly documented. And by the way: Ruby != Perl. Or maybe make $1 a real global variable? -- http://bugs.ruby-lang.org/