Hi,

At Mon, 29 Sep 2008 09:59:18 +0900,
Procek wrote in [ruby-talk:316286]:
>    i=0
>    while (i < splitted[2].to_i)
>      tmp += f.getc.chr #Here I have an error...
>    end

This is an inifinite loop.

    splitted[2].to_i.times do
    end

or

    tmp = f.read(splitted[2].to_i)

work.


  FS = "\x1c"
  RS = "\x1e"

  File.open("abcdef", "rb") do |f|
    f.gets(FS).chomp(FS).split(RS).each do |x|
      s = x.split("_")
      tmp = f.read(s[2].to_i)
      File.open(s[0]+"-"+s[1]+".txt", "w") {|f2| f2.write(tmp)}
    end
  end

-- 
Nobu Nakada