title: How can same program in ruby accept input from user as well as command line arguments
body: <p>My ruby script gets certain inputs from command line arguments. It check if any of the command line argument is missing, then it prompts for an input from user. But i am not able to get input from user using gets. </p>
  
  <p>Sample code: test.rb</p>
  
  <pre><code>name=""
  ARGV.each do|a|
      if a.include?('-n')
          name=a
          puts "Argument: #{a}"
      end
  end
  if name==""
      puts "enter name:"
      name=gets
      puts name
  end
  </code></pre>
  
  <p>Running script: <code>ruby test.rb raghav-k</code></p>
  
  <p>Results in the error:</p>
  
  <pre><code>test.rb:6:in `gets': No such file or directory - raghav-k (Errno::ENOENT)
      from test.rb:6:in `gets'
      from test.rb:6:in `&lt;main&gt;'
  </code></pre>
  
  <p>Any pointers in this direction will be really grateful
  Thanks
  Sandy</p>