2007-04-29
初めてのRuby
ひとまず書き捨てのスクリプトを。
#!/usr/bin/ruby -w
require 'open-uri'
url = "http://www.8bitpeoples.com/discography_gfx.php"
r = Regexp.new("http:\/\/.*?\.mp3")
source = open(url)
source.each do |line|
if line =~ r
print line[r] + "\n"
end
end
ex) wget `./spoil.rb`
もう少し短くきれいにif文なしで書けたりしそうですが、今はあんまり気にしないでおこうと思います。当面はこういうのをたくさん書いて手に馴染ませたいと思います。