From: Robert Klemme Date: 2012-08-29T16:31:40+09:00 Subject: Re: What Really is Happening? On Wed, Aug 29, 2012 at 5:58 AM, Jam wrote: > > > On Aug 28, 2012, at 9:46 PM, Pepe Pew wrote: > >> Hello, I need your help. >> I just made the file "analyzer.rb" and placed on a folder. >> This file has the code: >> >> line_count = 0 >> File.open("text.txt").each { |line| line_count += 1 } >> puts line_count >> >> I tried to run it by CMD, but it doesn't oppened the "text.txt" file. >> "analyzer.rb" and "text.txt" are on the same folder. > > it looks like you're executing the script from a different directory than it exists in. The important bit here is to execute the script from the directory where text.txt sits since the path is hardcoded in the script. Btw, in Ruby 1.9.3 you can do line_count = File.foreach("text.txt").count :-) Kind regards robert -- remember.guy do |as, often| as.you_can - without end http://blog.rubybestpractices.com/