>
> Sometimes, reformulating the problem helps, too. If you could provide
> abbreviate examples of what you want to achieve, we can give you more
> specific advice, I guess.
>
> --
> Phillip Gawlowski
>
> Though the folk I have met,
> (Ah, how soon!) they forget
> When I've moved on to some other place,
> There may be one or two,
> When I've played and passed through,
> Who'll remember my song or my face.

I probably should have just started with an example.  After typing out a
simplified version of my code, I think I can pretty easily re-arrange my
loop(s) to achieve what I need to do.  For the sake of giving this
thread resolution here's a simplified version of what I am currently
doing:

=begin code

input_urls = [www.url1.com, www.url2.com, www.url3.com]

index_file = File.new('index.html', 'w+')
index_file.puts %&<html><head><title>Page title</title></head><body>&

input_urls.length.times do |x|

  source << input_urls.pop
  #source is actually an array in my real code, my input array actually
has more than just urls in it but i'm trying to keep this simpler

  extract_urls = Url_finder.new("#{source}")
  extracted_urls = extract_urls.method_to_parse_for_certain_urls

  index_file.puts %&
  search_file = File.new("search#{x}.html", "w+")

  search_file.puts
%&<html><head><title>searchpage</title></head><body>center><body>&

  extracted_urls.length.times do |i|

    content = Content_finder.new("#{extracted_urls[i]})

    pics = content.method_to_find_pic_links #pics is an array of urls

      pics.length.times do |y|
        search_file.puts %&<img src="#{pics[y]}>&
      end

    end
    search_file.puts %&</body></html>&
    search_file.close
  end
end

index_file.puts %&</body></html>
index_file.close

=end code

With the new javascript content I want to add I need to put non-static
code in the line:

search_file.puts
%&<html><head><title>searchpage</title></head><body>center><body>

The new javascript code needs to reference the loop iteration number...

So, I guess all I need to do is start extracting content (via my
Content_finder class) earlier in the loop, and some other minor
adjustments... although I haven't really thought it out yet.  I've never
tried it, but I assume I could access my main loop variable 'i' from the
inner loop?  The dependency of my index.html and search'x'.html files is
what seems to be the confusing part for me.

Also would still love to hear any ideas on a good way to separate the
data extraction and web page creation parts of this.  As I said earlier,
I have very little programming background, but this loop is making me
think I'm creating too many dependencies and there's maybe a totally
different way to go about achieving the same end result.  But, judging
by the replies so far, maybe I am going about this the best way and just
need to re-think my loop.

-- 
Posted via http://www.ruby-forum.com/.