summaryrefslogtreecommitdiffstats
path: root/sample
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>1999-11-29 06:33:02 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>1999-11-29 06:33:02 +0000
commit122d4994c7ce43b08e66da1c7d1fdce549a3f3ba (patch)
tree0d50e885e5bc53706f2dc9051b6d45146a0dd058 /sample
parent806ff7412735cc554d9fd79e550466e7ba9d0f2a (diff)
downloadruby-122d4994c7ce43b08e66da1c7d1fdce549a3f3ba.tar.gz
ruby-122d4994c7ce43b08e66da1c7d1fdce549a3f3ba.tar.xz
ruby-122d4994c7ce43b08e66da1c7d1fdce549a3f3ba.zip
19991129
git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@572 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'sample')
-rw-r--r--sample/freq.rb5
1 files changed, 2 insertions, 3 deletions
diff --git a/sample/freq.rb b/sample/freq.rb
index 4e0206c11..362753f71 100644
--- a/sample/freq.rb
+++ b/sample/freq.rb
@@ -1,9 +1,8 @@
# word occurrence listing
# usege: ruby freq.rb file..
freq = Hash.new(0)
-while gets
- while sub!(/\w+/, '')
- word = $&
+while line = gets()
+ line.scan(/\w+/) do |word|
freq[word] += 1
end
end