summaryrefslogtreecommitdiff
path: root/sample/freq.rb
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
commit40517ecac82e4b406227bd30fd89d05c2e90bc87 (patch)
tree0d50e885e5bc53706f2dc9051b6d45146a0dd058 /sample/freq.rb
parent2b49047143d1e10d6dd5d2359dba2d302fa07c66 (diff)
19991129
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@572 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'sample/freq.rb')
-rw-r--r--sample/freq.rb5
1 files changed, 2 insertions, 3 deletions
diff --git a/sample/freq.rb b/sample/freq.rb
index 4e0206c..362753f 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