[#36069] 日本語に混じった URL を抜き出したい — keiichi matsunaga <ma2@...>

 松永です。

26 messages 2002/10/02
[#36072] Re: 日本語に混じった URL を抜き出したい — keiichi matsunaga <ma2@...> 2002/10/02

 松永です。

[#36073] Re: 日本語に混じった URL を抜き出したい — SAITO Shukaku <shukaku@...> 2002/10/02

At Wed, 2 Oct 2002 13:51:42 +0900,

[ruby-list:36204] Re: ARGF を 2 回読み出したい場合について

From: Tokita Kousui <ktokita@...>
Date: 2002-10-26 15:33:45 UTC
List: ruby-list #36204
時田です

元記事の素直な答えがあるのかわからないのでチャチャです (ごめんなさい)
下の5つを考えてみました
1つ外れがあります

==test1==
#!/usr/bin/ruby
list = []
while line = ARGF.gets
  list << ARGF.filename
  print "1" + line
end

list = list.uniq
while file = list.shift
  File.foreach(file) do |line|
	print "2" + line
  end
end

==test2==
#!/usr/bin/ruby
all = ARGF.read

all.each_line{ |line|
  print "1" + line
}

all.each_line{ |line|
  print "2" + line
}

==test3==
#!/usr/bin/ruby
if fork == nil then
  while line = ARGF.gets
	print "1" + line
  end
else
  while line = ARGF.gets
	print "2" + line
  end
end
					
==test4==
#!/usr/bin/ruby
Thread.start{
  while line = ARGF.gets
	print "1" + line
  end
}

while line = ARGF.gets
  print "2" + line
end
					
==test5==
#!/usr/bin/ruby
arg = ARGV.dup

if not File::exist?("fase") then
  fase = 1
else
  f = open("fase")
  fase = f.read
  f.close
  fase = fase.to_i
end
  
if fase == 1 then
  while line = ARGF.gets
	print "1" + line
  end
elsif fase == 2 then
  while line = ARGF.gets
	print "2" + line
  end
else
  File::unlink("fase")
  exit
end

f = open("fase", "w")
f.print (fase + 1).to_s
f.close

cmd = $0
cmd2 = ""
arg.each{|x| cmd2 += " , \"#{x}\"" }
eval( "exec(\"#{cmd}\" #{cmd2})" )

=========

-- 
時田 <ktokita@where-i.net>
http://ibis.where-i.net/

In This Thread