#!/usr/local/bin/ruby
=begin
http://foo.bar.co.jp/(ほげ)
というパターンがあれば
ほげ
に置換する。
=end
require 'kconv'
$euc = false
while /^-\w/ =~ ARGV[0]
case ARGV[0]
when /^-e$/
$euc=true;
end
ARGV.shift
end
$euc = true if /euc|-e$/ =~ $0
while line=gets
line = Kconv::toeuc(line)
line.gsub!(%r,((https?|ftp|mailto)://[-A-z0-9_.:~+%/]+)\(([^()]+)\),,
"\\3")
print (if $euc then line else Kconv::tojis(line) end)
end