I'm confused. I'm attempting to query a user for a filename to be
processed, and then I want to open that file for parsing. However, I'm
getting an error that the file does not exist. Hopefully someone can
Here is my code:
# Get filename
puts ("Please enter the name of the file you wish to process: ")
filename = gets
puts ("File to be processed: " + filename)
puts "Does not exist."
# Process file
File.open(filename, "r") do |input_file|
while line = input_file.gets
puts line if line =~ /^[O] \[/
Running this (Windows XP) produces the following:
C:\Documents and Settings\jcalivar\Desktop>ruby
Please enter the name of the file you wish to extract requirements
File to be processed: fred.txt
Does not exist.
RequirementsExtractor.rb:35:in `initialize': No such file or directory
- fred.txt (Errno::ENOENT)
from RequirementsExtractor.rb:35:in `open'
I can't figure this out - because "fred.txt" certainly *does* exist on
my desktop. Help!