J
Joe Ruby MUDCRAP-CE
I have:
File.foreach(data_file) do |line|
line.strip!
puts line
base_name = line
puts line
base_name.sub!('www.', '')
base_name.sub!(/\.\w+$/, '')
puts line
end
Which outputs:
www.domain.com
www.domain.com
domain
WHY is var line getting changed by operations on var base_name? Isn't
'base_name = line' supposed to create a copy? '=' in this case seems to
be acting like an alias or something.
BTW, is there a foreach function that automatically strips off the
newlines from line? Returning the record separators is silly.
Currently hating Ruby,
Joe
File.foreach(data_file) do |line|
line.strip!
puts line
base_name = line
puts line
base_name.sub!('www.', '')
base_name.sub!(/\.\w+$/, '')
puts line
end
Which outputs:
www.domain.com
www.domain.com
domain
WHY is var line getting changed by operations on var base_name? Isn't
'base_name = line' supposed to create a copy? '=' in this case seems to
be acting like an alias or something.
BTW, is there a foreach function that automatically strips off the
newlines from line? Returning the record separators is silly.
Currently hating Ruby,
Joe