Comfort Eagle wrote:

> Comfort Eagle wrote:
>> Paul Lutus wrote:
>>> Comfort Eagle wrote:
>>> 
>>> / ...
>>> 
>>>> Interesting.  Newb Q, I'm sure, but when I put that in a while loop I
>>>> get: "private method `gsub!' called for ..."  /me googles & still
>>>> scratches head.
>>>> 
>>>> "
>>>> res.each do |url|
>>>>   puts url.gsub!( /^http:\/\//i, '')
>>>> end
>>> 
>>> What is "res"? Is it an array of strings?
> 
> Better:
> I thought it was array of strings & looks like it to me??
> 
>   res = dbh.query("Select url FROM sites")
>   while url = res.fetch_row do
>     puts url.gsub!( /^http:\/\//i, '')
>   end

Well, it's easy enough to find out.

Before you apply "gsub!", test the class:

>   res = dbh.query("Select url FROM sites")
>   while url = res.fetch_row do

puts url.class  # Add this. Read the result. Then decide what to do.

>     puts url.gsub!( /^http:\/\//i, '')
>   end

Chances are there's a non-string in your incoming data.

Also "puts url.gsub!(...)" doesn't make much sense. It returns nil if there
were no substitutions (assuming "url" is a string), not what you want.

-- 
Paul Lutus
http://www.arachnoid.com