Tom Reilly
9/18/2007 9:23:00 PM
Try changing the code to:
file_in = File.new("whatever")
file_in.each do |x|
url = x.chomp + ".net"
gud luck
Chuck Dawit wrote:
> I'm reading a file line by line and trying to remove the newline at the
> end of each line so that I can rebuild the url with the "www" and the
> ".net" at the beginning and end. Does anyone know how I can remove the
> newline char at the end of each line? Also if the url doesn't work/exist
> I don't want the script to crash I want to keep moving through the file
> its reading.
>
> begin
> while (line = f.readline)
> line = line =~ /(.*?)\n/
> url = "www." + line + ".net"
>
> open(url) { |page| page_content = page.read()
> puts "link exists"
> }
> end
> rescue
> puts "link does not exist"
>
> rescue EOFError
> f.close
> end
>