Created
April 13, 2011 17:17
-
-
Save colinsurprenant/917939 to your computer and use it in GitHub Desktop.
ruby unix style pipe/filter example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rubygems' | |
require 'benchmark' | |
line_count = 0 | |
elapsed = Benchmark.realtime do | |
while (line = $stdin.gets) | |
puts(line) | |
line_count += 1 | |
end | |
$stdin.close | |
end | |
$stderr.puts("processed #{line_count} lines in #{"%.2f" % elapsed}") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment