ARGV and ARGF : ARGF « Development « Ruby






ARGV and ARGF


ARGV << "myFile.txt"
print while gets

# ARGV (or $*) is an array, and each of its elements is a filename submitted on the command line. 
# You can apply any method to ARGV that you might apply to any other array. 


p ARGV # => ["sonnet_119.txt"]

# or:

ARGV#[0] # => ["sonnet_119.txt"]

 








Related examples in the same category

1.ARGF ($<) is a virtual concatenation of all the files that appear on the command line.
2.ARGF.gets