| Name | Aliases | Description |
|---|---|---|
| $! | $ERROR_INFO | The exception information message set by the last 'raise' (last exception thrown). |
| $@ | $ERROR_POSITION | Array of the backtrace of the last exception thrown. |
| $& | $MATCH | The string matched by the last successful pattern match in this scope. |
| $` | $PREMATCH | The string to the left of the last successful match. |
| $' | $POSTMATCH | The string to the right of the last successful match. |
| $+ | $LAST_PAREN_MATCH | The last group of the last successful match. |
| $1 to $9 | The Nth group of the last successful regexp match. | |
| $~ | $LAST_MATCH_INFO | The information about the last match in the current scope. |
| $= | $IGNORECASE | The flag for case insensitive, nil by default (deprecated). |
| $/ | $INPUT_RECORD_SEPARATOR, |
The input record separator, newline by default. |
| $\ | $OUTPUT_RECORD_SEPARATOR or $ORS | The output record separator for the print and IO#write. Default is nil. |
| $, | $OUTPUT_FIELD_SEPARATOR or $OFS | The output field separator for the print and Array#join. |
| $; | $FIELD_SEPARATOR, |
The default separator for String#split. |
| $. | $INPUT_LINE_NUMBER or $NR | The current input line number of the last file that was read. |
| $< | $DEFAULT_INPUT | An object that provides access to the concatenation of the contents of all the files given as command-line arguments, or $stdin (in the case where there are no arguments). Read only. |
| $FILENAME | Current input file from |
|
| $> | $DEFAULT_OUTPUT | The destination of output for Kernel.print and Kernel.printf. The default value is $stdout. |
| $_ | $LAST_READ_LINE | The last input line of string by gets or readline. |
| $0 | Contains the name of the script being executed. May be assignable. | |
| $* | ARGV | Command line arguments given for the script. Also known as ARGV |
| $$ | $PROCESS_ID, $PID or Process.pid | The process number of the Ruby running this script. |
| $? | $CHILD_STATUS | The status of the last executed child process. |
| $: | $LOAD_PATH | Load path for scripts and binary modules by load or require. |
| $" |
|
The array contains the module names loaded by require. |
| $stderr | The current standard error output. | |
| $stdin | The current standard input. | |
| $stdout | The current standard output. | |
| $-d | $DEBUG | The status of the -d switch. Assignable. |
| $-K | $KCODE | Character encoding of the source code. |
| $-v | $VERBOSE | The verbose flag, which is set by the -v switch. |
| $-a | True if option -a ("autosplit" mode) is set. Read-only variable. | |
| $-i | If in-place-edit mode is set, this variable holds the extension, otherwise nil. | |
| $-l | True if option -l is set ("line-ending processing" is on). Read-only variable. | |
| $-p | True if option -p is set ("loop" mode is on). Read-only variable. | |
| $-w | True if option -w is set. |
Predefined Constants:
- _FILE_ (current file)
- _LINE_ (current line)
- _dir_ (current directory)