On Wed, Jan 29, 2014 at 4:58 PM, Serguei Cambour <lists / ruby-forum.com> wrote:
> Fixed it.
> I passed a file name as follows at the start up file:
>
> file_name = ARGV.first
>
> in th terminal I just taped in:
>
> ruby bin/my_ruby_file.rb data.txt
>
> When hard coding te file name as folllows:
>
> file_name = 'data.txt'
>
> there was no problem.
>
> After changing it to:
>
> file_name = ARGV.pop

In any case, if you want to support passing arguments to the scripts
and also reading from stdin, you can avoid using the Kernel method,
and as Abinoam suggested, use $stdin.gets. This way you don't have to
do any workarounds on ARGV to have gets work on stdin.

Jesus.