summaryrefslogtreecommitdiffstats
path: root/sample
diff options
context:
space:
mode:
authorknu <knu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2002-12-19 20:30:05 +0000
committerknu <knu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2002-12-19 20:30:05 +0000
commitdf5b31e34eef759b85447971526c6443ab017fa1 (patch)
treed891d2e61cd3b7eb00e73b49a533b8ad85bb0fc9 /sample
parentf8a5273c820871700563a57acc87ac8bb5e933ae (diff)
downloadruby-df5b31e34eef759b85447971526c6443ab017fa1.tar.gz
ruby-df5b31e34eef759b85447971526c6443ab017fa1.tar.xz
ruby-df5b31e34eef759b85447971526c6443ab017fa1.zip
The use of $_ and ~/RE/ is discouraged.
git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@3182 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'sample')
-rw-r--r--sample/dir.rb6
1 files changed, 4 insertions, 2 deletions
diff --git a/sample/dir.rb b/sample/dir.rb
index 2465c4d68..b62738394 100644
--- a/sample/dir.rb
+++ b/sample/dir.rb
@@ -2,8 +2,10 @@
# list all files but .*/*~/*.o
dirp = Dir.open(".")
for f in dirp
- $_ = f
- unless (~/^\./ || ~/~$/ || ~/\.o/)
+ case f
+ when /^\./, /~$/, /\.o/
+ # do not print
+ else
print f, "\n"
end
end