"Markus Blasl" <blasl / fzi.de> schrieb im Newsbeitrag news:3F2A565A.1080500 / fzi.de... > Hi, > > can anyone give a hint, why ruby skips the input, when i run this > following code? > > thanks, > Markus > > #!/usr/bin/ruby > def search() > puts "Suchbegriff: "; > search=gets; search=$stdin.gets; > chop > search = $_ > search = "Welt"; > ARGV.each do |test| > File.open("#{test}", "r") do |afile| Don't need the #{} here: File.open(test, "r") do |afile| > if (afile.gets =~ /#{search}/i) This reads only one line, is that desired? > puts test.to_s puts test > end > end > end > end > search() gets reads from ARGF, i.e. the arguments are interpreted as file names and gets reads from them as in cat.rb: #!ruby while ( line = gets ) ; puts line ; end Regards robert