Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/ruby/20.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在ruby命令中传递变量?_Ruby_Linux - Fatal编程技术网

在ruby命令中传递变量?

在ruby命令中传递变量?,ruby,linux,Ruby,Linux,prueban8文件内容为: $F[1] > "2" and $F[1] < "4" and $F[3] == "pet" 但我无法传递变量出现错误 ,输入意外结束 我如何解决这个问题?我用这个解决了这个问题 ruby -a -F';' -ne 'input = File.read("prueban8") ; eval ( input + " ; puts $F[2] end") ' ppp.txt 我很好奇将代码放在另一个文件中的好处,如

prueban8
文件内容为:

 $F[1] > "2" and $F[1] < "4" and $F[3] == "pet"   
但我无法传递变量出现错误 ,输入意外结束

我如何解决这个问题?

我用这个解决了这个问题

ruby   -a   -F';' -ne      'input = File.read("prueban8")   ; eval ( input +  " ; puts  $F[2] end")   '  ppp.txt

我很好奇将代码放在另一个文件中的好处,如果只将其包含在您编写的脚本中会更快?我正在使用jquery serialize命令到sinatra framework的变量来过滤数据
ruby   -a   -F';' -ne      'input = File.read("prueban8")   ; eval ( input +  " ; puts  $F[2] end")   '  ppp.txt