$_
is last read line. Also
print
- if no argument given print content of$_
~/regexp/
- short for$_=~/regexp/
In Ruby 1.8, you have four methods in Kernel
that operate on $_
:
chop
chomp
sub
gsub
print
- if no argument given print content of$_
In Ruby 1.9, these four methods exist only if your script uses -n
or -p
.
If you want to print some variable often then use trace_var(:var_name){|a|p a}