lib/rubyc/cli.rb in rubyc-0.0.17 vs lib/rubyc/cli.rb in rubyc-0.1.0.alpha

- old
+ new

@@ -32,12 +32,12 @@ puts sum end desc :select, "Apply Enumerable#select on each line" def select(code) - proc = eval("Proc.new{|line| l = line; #{code}}") - $stdin.each do |line| - puts line if proc.call(line.chomp) + proc = eval( "Proc.new{|line,index| l = line; lnum = index + 1;#{code}}" ) + $stdin.each_line.each_with_index do |line, index| + puts line if proc.call(line.chomp, index) end end desc :count_by, "Count the number of lines that have the same property. The property is defined by the return value of the given the block" def count_by(code = nil)