Ruby
Randomly split input lines.
#!/usr/bin/env ruby
files = ARGV.collect { |fname| File.new(fname, 'w') }
$stdin.each { |line| files[rand(files.length)].puts line }
#!/usr/bin/env ruby
files = ARGV.collect { |fname| File.new(fname, 'w') }
$stdin.each { |line| files[rand(files.length)].puts line }
Refactorings
No refactoring yet !
November 24, 2011,
November 24, 2011 04:42,
permalink
No rating.
Login to rate!
ERROR_BAD_DUPLICATES
November 24, 2011,
November 24, 2011 04:42,
permalink
No rating.
Login to rate!
ERROR_BAD_DUPLICATES
My first Ruby script. I'm curious how to improve it.
Funnily enough, I was stymied by the while/for syntax. So, I used the more functional style.