| $!Exception === $! unless $!.nil? | read-only thread-local  The last exception, that was thrown and rescued in the current context.```ruby
> 0 / 0 rescue $!
# ⇒ <ZeroDivisionError: divided by 0>
> begin
>   0 / 0
> rescue
>   $!
> end
# ⇒ <ZeroDivisionError: divided by 0>
> 0 / 0
# ZeroDivisionError: divided by 0
# from (pry):67:in `/'
> $!
# ⇒ nil
```Locals to the
 rescueclause. | 
  | $"Array === $" | read-only  Array of strings,
        containing absolute paths to loaded files.```ruby
> $"
# ⇒ [
#  [  0] "enumerator.so",
#  [  1] "/…/lib/ruby/2.0.0/x86_64-linux/enc/encdb.so",
#  [  2] "/…/lib/ruby/2.0.0/x86_64-linux/enc/trans/transdb.so",
#  [  3] "/…/lib/ruby/site_ruby/2.0.0/rubygems/defaults.rb",
#  [  4] "/…/lib/ruby/2.0.0/x86_64-linux/rbconfig.rb",
#  …
#  [227] "/…/lib/ruby/2.0.0/dl.rb"
# ]
```Files, loaded within both
 Kernel’sload,require,require_relativedirectives and platform-specific
        DL/Fiddle,
        are shown in the list. | 
  | $$Fixnum === $$ | read-only  Current process ID.```ruby
> $"
# ⇒ 8603
> Process.pid
# ⇒ 8603
```
 | 
  | $&String === $& unless $&.nil? | read-only thread-local  The matched string from the previous successful pattern match.```ruby
> "foo bar baz".match /foo|bar|baz/
# ⇒ <MatchData "foo">
> $&
# ⇒ "foo"
> "foo bar baz".gsub /foo|bar|baz/, "ggg"
# ⇒ "ggg ggg ggg"
> $&
# ⇒ "baz"
> "foo bar baz".match /foobarbaz/
# ⇒ nil
> $&
# ⇒ nil
```Locals to the pattern match scope.
 | 
  | $'String === $' unless $'.nil? | read-only thread-local  The rest of the string after the matched substring in the previous successful pattern match.```ruby
> "foo bar baz".match /foo|bar|baz/
# ⇒ <MatchData "foo">
> $'
# ⇒ " bar baz"
> "foo bar baz".gsub /foo|bar|baz/, 'ggg'
# ⇒ "ggg ggg ggg"
> $'
# ⇒ ""
> "foo bar baz".match /foobarbaz/
# ⇒ nil
> $'
# ⇒ nil
```Locals to the pattern match scope.
 | 
  | $*Array === $* | read-only  The command line arguments passed to the currently executed ruby script.```ruby
~ pry --simple-prompt
> $*
# ⇒ [
#  [0] "--simple-prompt"
# ]
> ARGV
# ⇒ [
#  [0] "--simple-prompt"
# ]
```An alias for
 ARGV. | 
  | $+String === $+ unless $+.nil? | read-only thread-local  The last captured match from the previous successful pattern match.```ruby
> "foo bar baz".match /(foo) (bar) baz/
# ⇒ <MatchData "foo bar baz" 1:"foo" 2:"bar">
> $+
# ⇒ "bar"
> "foo bar baz".scan (/a(\S)/) { |m| puts m }
# r
# z
# ⇒ "foo bar baz"
> $+
# ⇒ "z"
> "foo bar baz".match /foo bar baz/
# ⇒ <MatchData "foo bar baz">
> $+
# ⇒ nil
```Locals to the pattern match scope. Contains
 nilif there was no capture (even while match was successful.) | 
  | $,String === $, unless $,.nil? | read-write  Separator for both
    ```ruby
> print "foo", "bar", "baz"
# foobarbaz⇒ nil
> %w[foo bar baz].join
# ⇒ "foobarbaz"
> $,='%'
# ⇒ "%"
> print "foo", "bar", "baz"
# foo%bar%baz⇒ nil
> %w[foo bar baz].join
# ⇒ "foo%bar%baz"
```Kernel#printandArray#join.Defaults to nil.
 | 
  | $-0
 
 $/String === $-0 unless $-0.nil?String === $/ unless $/.nil?
 | read-write  Input record separator.```ruby
> $-0='%'
# ⇒ "%"
> gets
f
o
o
%
# ⇒ "f\no\no\n%"
~ ruby -045 /…/bin/pry
> gets
f
o
o
%
# ⇒ "f\no\no\n%"
> 
```Defaults to
 \n. May be set with the-0command line parameter (as octal value.) | 
  | $-F
 
 $;String === $-F unless $-F.nil?String === $: unless $:.nil?
 | read-write  Default field separator for ```ruby
> $-F
# ⇒ nil
> "foo bar baz".split
# ⇒ [
#  [0] "foo",
#  [1] "bar",
#  [2] "baz"
# ]
> $-F='%'
# ⇒ "%"
> "foo bar baz".split
# ⇒ [
#  [0] "foo bar baz"
# ]
> "foo%bar%baz".split
# ⇒ [
#  [0] "foo",
#  [1] "bar",
#  [2] "baz"
# ]
> $-F == $;
# ⇒ true
```String#split.Defaults to
 nil. May be set with the-Fcommand line parameter. | 
  | $-I
 
 $:Array === $-IArray === $:
 | read-only  Array of include paths.```ruby
> $-I
# ⇒ [
#  [ 0] "/…/gems/rubygems-bundler-1.1.0/lib",
#  [ 1] "/…/gems/bundler-1.2.3/lib",
#  [ 2] "/…/gems/coderay-1.0.8/lib",
#  [ 3] "/…/gems/slop-3.4.3/lib",
#  …
#  [14] "/…/lib/ruby/2.0.0/x86_64-linux"
# ]
> $-I == $:
# ⇒ true
```Absolute paths to be searched by
 Kernel.loadand/orKernel.require. | 
  | $-KString === $-K unless $-K.nil? | obsolete read-write  Determines the encoding to be used whilst parsing ```ruby
> $-K
# (pry):13: warning: variable $KCODE is no longer effective
# ⇒ nil
```.rbfiles.One should avoid using that variable since
 ruby-1.9. | 
  | $-WFixnum === $-W | read-only  Current verbosity level.```ruby
> $-W
# ⇒ 1
> exit
~ ruby -v /…/bin/pry
# ruby 2.0.0dev (2012-12-01 trunk 38126) [x86_64-linux]
# /…/gems/method_source-0.8.1/lib/method_source/code_helpers.rb:38: warning: assigned but unused variable - e2
# …
# /…/gems/pry-0.9.11.4/lib/pry/pry_class.rb:446: warning: instance variable @critical_section not initialized
> $-W
# /…/gems/awesome_print-1.1.0/lib/awesome_print/inspector.rb:114: warning: instance variable @force_colors not initialized
# ⇒ 2
> exit
~ ruby -W0 /…/bin/pry
> $-W
# ⇒ 0
>
```Defaults to
 1. May be set to0with the-W0command line arg
      and to2with one of-w,-v, or--verboseswitches. | 
  | $-a∈ [true, false] | read-only  Denotes whether the auto-split mode was enabled with ```ruby
~ cat > test-a-switch.rb 〈〈EOF
# heredoc> # encoding: utf-8
# heredoc> puts "LINE=[#{\$_.strip}]"
# heredoc> puts "\$F=#{\$F}"
# heredoc> EOF
~ ruby -a -n test-a-switch.rb test-a-switch.rb
# LINE=[# encoding: utf-8]
# $F=["#", "encoding:", "utf-8"]
# LINE=[puts "LINE=#{$_.strip}"]
# $F=["puts", "\"LINE=\#{$_.strip},"]
# LINE=[puts "$F=#{$F}"]
# $F=["puts", "$F=\#{$F}\""]
~ ruby -n test-a-switch.rb test-a-switch.rb
# LINE=# encoding: utf-8
# $F=
# LINE=puts "LINE=#{$_.strip}"
# $F=
# LINE=puts "$F=#{$F}"
# $F=
```-acommand line argument.
 -aswitch makes sense when used together with either-por-nargs.
    In auto-split mode, Ruby executes$F = $_.splitat the beginning of each loop. | 
  | $-d∈ [true, false] | read-only  Denotes whether the debug mode was enabled with ```ruby
~ cat > test-d-switch.rb 〈〈EOF
# heredoc> puts "DEBUG MODE: #{\$-d}"
# heredoc> EOF
~ ruby -d test-d-switch.rb
# Exception `LoadError' at /…/lib/ruby/site_ruby/2.0.0/rubygems.rb:1264 - cannot load such file -- rubygems/defaults/operating_system
# Exception `LoadError' at /…/lib/ruby/site_ruby/2.0.0/rubygems.rb:1273 - cannot load such file -- rubygems/defaults/ruby
# DEBUG MODE: true
```-dswitch.
 | 
  | $-i∈ [true, false] | read-only  Value of the ```ruby
~ cat > test-i-switch.rb << EOF
\$_.upcase!
puts "i-switch: #{\$-i}"
EOF
~ ruby -p -i.bak test-i-switch.rb test-i-switch.rb
~ cat test-i-switch.rb
# i-switch: .bak
# $_.UPCASE!
# i-switch: .bak
# PUTS "I-SWITCH: #{$-I}"
```-icommand line argument, if given.Defaults to
 nil. When provided, this argument enables inplace-edit mode; the parameter specifies an extension of
    backup file to be created. | 
  | $-l∈ [true, false] | read-only  Denotes whether the automatic
      line-ending processing mode was enabled with ```ruby
# Could not invent a meaningful example :-(
```-lswitch.Automatic line-endings sets
 $\to
      the value of$/, and (when used with either-por-nargs) chops every line read usingchop!. | 
  | $-p∈ [true, false] | read-only  Denotes whether the “gets loop around” mode was enabled with ```ruby
while gets
 …
end
```-pswitch.
 -pswitch acts mostly like-nsibling with one exception: it prints the value
      of variable$_at the each end of the loop.For some unknown reason there is no internal global
      to get aknowledged whether the
 -ncommand line switch was given. In case it were, Ruby is to assume
      the following loop around your script, which provides an iteration over filename arguments somewhat likesed -nandawkdo. An example of usage follows:```ruby
~ echo "foo bar baz" | ruby -p -e '$_.tr! "o-z", "O-Z"'
# ⇒ fOO baR baZ
``` | 
  | $-v
 
 $-w∈ [true, false] | read-only  Denotes whether the verbose mode
      was enabled with either ```ruby
~ cat > test-v-switch.rb 〈〈EOF
# heredoc> puts "VERBOSE MODE: #{\$-v}"
# heredoc> EOF
~ ruby -v test-v-switch.rb
# ruby 2.0.0dev (2012-12-01 trunk 38126) [x86_64-linux]
# VERBOSE MODE: true
~
```-vor-wswitch.
 | 
  | $.Fixnum === $. | read-only  Number of the last line read from the current input file ```ruby
ARGV.replace ["file1"] # file1 ≡ 'a\nb\nc\nd'
ARGF.readlines # Returns the contents of file1 as an Array
$.
# ⇒ 4
```ARGF.ARGF is a stream designed to use in scripts that process files given as command-line arguments or passed in via
 STDIN. | 
  | $0…$9String === $0 unless $0.nil?String === $1 unless $1.nil?
 String === $2 unless $2.nil?
 String === $3 unless $3.nil?
 String === $4 unless $4.nil?
 String === $5 unless $5.nil?
 String === $6 unless $6.nil?
 String === $7 unless $7.nil?
 String === $8 unless $8.nil?
 String === $9 unless $9.nil?
 | read-only  The ```ruby
> "foo bar baz".match(/(foo) (bar)/) 
# ⇒ <MatchData:0x18cb9f4>
> $1
# ⇒ "foo"
> $2
# ⇒ "bar"
> $3
# ⇒ nil
```N-thcapture of the previous successful pattern match.Defaults to
 nilif the match failed or ifNis greater than an amount of captured groups. | 
  | $<ARGF === $< | read-only  Read‐only alias for ARGF.```ruby
> $<.class
# ⇒ ARGF.class < Object
```
 | 
  | $=∈ [true, false] | obsolete  ```ruby
> $=
# (pry):23: warning: variable $= is no longer effective
# ⇒ false
```
 | 
  | $>IO === $> | read-write  Standard output stream.```ruby
> $> = File.new('/tmp/foo', 'w')
# ⇒ <File:/tmp/foo>
# -rw-r--r-- 1 am users 0 Feb 27 12:41 /tmp/foo
> puts "bar baz"
# ⇒ nil
> exit
~ cat /tmp/foo
# bar baz
```
 | 
  | $?Process::Status === $? unless $?.nil? | read-only  Exit status of the last terminated process within current context.```ruby
> `ls FooBarBaz`
# ls: невозможно получить доступ к FooBarBaz: Нет такого файла или каталога
# ⇒ ""
> $?
# ⇒ <Process::Status: pid 31718 exit 2>
```
 | 
  | $@Array === $@ unless $@.nil? | read-only thread-local  Shorthand to ```ruby
> 0 / 0 rescue $@
# ⇒ [
#  [ 0] "(pry):7:in `/'",
#  [ 1] "(pry):7:in `__pry__'",
#  …
#  [23] "/…/bin/ruby_noexec_wrapper:14:in `'"
# ]
```
</td>
</tr>$!.backtraceLocals to the
 rescueclause. 
  | $\String === $\ unless $\.nil? | read-write  Appended to ```ruby
> $\='%'
# ⇒ "%"
> print 'foo', 'bar', 'baz'
# ⇒ %foobarbaz%=> nil
```Kernel.printoutput.Defaults to
 nil, or to$/if the-lswitch was given. |  
  | $_String === $_ unless $_.nil? | read-only thread-local  Last ```ruby
> gets
foo
# ⇒ "foo\n"
> $_
# ⇒ "foo\n"
```Stringread fromIOby one ofKernel.gets,Kernel.readlineor siblings.Widely used with
 -pand-nswitches. |  
  | $`String === $` unless $`.nil? | read-only thread-local  The
      rest of the string before the matched substring in the previous successful pattern match.```ruby
> "foo bar baz".match /bar|baz/
# ⇒ <MatchData "bar">
> $`
# ⇒ "foo "
> "foo bar baz".gsub /foo|bar|baz/, 'ggg'
# ⇒ "ggg ggg ggg"
> $`
# ⇒ "foo bar "
> "foo bar baz".match /foobarbaz/
# ⇒ nil
> $`
# ⇒ nil
```Locals to the pattern match scope.
 |  
  </tbody>
</table>
</div>
Credits to [Jim Neath](http://jimneath.org/2010/01/04/cryptic-ruby-global-variables-and-their-meanings.html) and
[runpaint](http://ruby.runpaint.org/globals), some examples came from these posts.| $~MatchData === $~ unless $~.nil? | read-only thread-local  The
      ```ruby
> "abc12def34ghijklmno567pqrs".gsub (/\d+/) { |m| p $~ }
# ⇒ <MatchData "12">
# ⇒ <MatchData "34">
# ⇒ <MatchData "567">
```MatchDatafrom the previous successful pattern match.
 |  |