Development/Etc.
Ruby를 이용한 Directory 보는 구문
sunyruru
2007. 5. 19. 16:49
# directory access
# list all files but .*/*~/*.o
dirp = Dir.open(".")
for f in dirp
case f
when /^\./, /~$/, /\.o/
# do not print
else
print f, "\n"
end
end
dirp.close
PHP 할때같은 기분이 든다.
상당히 짧은 코드
정규표현식도 바로 사용하는 것이 참 마음에 든다.
.*과 *~, *.o는 보안상 제외시킨다.