[表示 : 全て 最新50 1-99 101- 201- 301- 401- 501- 601- 701- 801- 901- 2chのread.cgiへ]
Update time : 03/16 20:58 / Filesize : 261 KB / Number-of Response : 970
[このスレッドの書き込みを削除する]
[+板 最近立ったスレ&熱いスレ一覧 : +板 最近立ったスレ/記者別一覧] [類似スレッド一覧]


↑キャッシュ検索、類似スレ動作を修正しました、ご迷惑をお掛けしました

Ruby 初心者スレッド Part 19



503 名前:498 mailto:sage [2008/05/12(月) 00:17:51 ]
できたー とりあえず動いてるっぽいです
#!/usr/bin/env ruby
require 'optparse'
if $0 == __FILE__
 printpattern = "%1$s:%2$s:%3$s" # filename:linnum:line
 print = proc { |filename,linenum,line| STDOUT << (printpattern %[filename, linenum, line]) << "\n" }
 filepatterns = wordpatterns = []
 ARGV.options { |opt|
  dest = wordpatterns
  opt.on('-f'  , '--filepattern')  { dest = filepatterns }
  opt.on('-w'  , '--wordpattern')  { dest = wordpatterns }
  opt.on('-p S' , '--printpattern S') {|s| printpattern = s }
  opt.order! { |v|
   if wordpatterns.__id__ == dest.__id__ v = eval(v) end; dest << v
  }
 }
 wordpatterns << /\n/
 re = Regexp.union(*wordpatterns)
 text = ''
 filepatterns.each { |filepattern|
  Dir.glob(filepattern) {|filepath|
   next if !File.file?(filepath)
   linenum = 1
   text = IO.read(filepath)
   text.scan(re) {|m|
    linenum += $~[0].count("\n")
    print.call(filepath, linenum, m) if "\n" != $~[-1]
   }
  }
 }
end






[ 続きを読む ] / [ 携帯版 ]

全部読む 前100 次100 最新50 [ このスレをブックマーク! 携帯に送る ] 2chのread.cgiへ
[+板 最近立ったスレ&熱いスレ一覧 : +板 最近立ったスレ/記者別一覧]( ´∀`)<261KB

read.cgi ver5.27 [feat.BBS2 +1.6] / e.0.2 (02/09/03) / eucaly.net products.
担当:undef