So I’m wondering how to process here docs in ruby, for example, this is the main loop in my program:
begin
word = gets
if word.nil?
next
end
command = word.chomp.to_s
print word
end until (word.eql? "EOI")
and I run it by doing ./file <<EOI
If the user changes what’s used as the terminating string, however, then the last line will clearly fail. Is there some global variable that lets me detect what the user has specified as a terminating string? If not, what’s the best way to handle <<EOI?
Thanks yall.
Sample input:
hello
world
EOI
Any reason why you don’t just loop until
word.nil?which would also be the case if the user sendsEOF(Ctrl-d)?