Best Practices mit STDIN in Ruby?

Ich möchte mich mit der Kommandozeilen-Eingabe in Ruby befassen:

> cat input.txt | myprog.rb
> myprog.rb < input.txt
> myprog.rb arg1 arg2 arg3 ...

Was ist der beste Weg, um es zu tun? Insbesondere möchte ich mich mit blank STDIN beschäftigen und hoffe auf eine elegante Lösung.

#!/usr/bin/env ruby

STDIN.read.split("\n").each do |a|
   puts a
end

ARGV.each do |b|
    puts b
end

Antworten auf die Frage(18)

Ihre Antwort auf die Frage