xxxxxxxxxx
# print all the lines in every file passed via command line that contains login
ARGF.each do |line|
puts line if line =~ /login/
end
xxxxxxxxxx
## One line: 1 2 3
$stdin.read # => "1 2 3"
$stdin.read # => nil (read again will be nil)
## Multiline:
# 1 2 3
# 4 5 6
$stdin.each do |line|
# line => "1 2 3"
end
## Example: Save stdin input to variable
input_arr = []
$stdin.each do |line| # line => "1 2 3"
line = line.split(" ") # line => %w[1 2 3] (array of strings)
line.each do |num|
input_arr.push num.to_i
end
end
# input_arr => %d[1 2 3 4 5 6] (array of int)
## look at source below for further info