Why are you modifying the tree? That sounds rather suspect to me.
If you weren't modifying the tree, then you would be better of simply serving it via Apache without loading it into memory and or HTML::Tree to begin with :).

So anyway, I was keeping my discussion tongue-in-cheek because I did not want to open another can of worms, but the real scenario is that HTML::Seamstress is a set of convenience functions for dynamic HTML generation via HTML::Tree and currently I use new_from_file but was thinking I could get a speedup by pre-parsing and cloning. But you are right, I probably should do some benchmarking on the two approaches before getting into a hissy.

But wait - there is a very good reason to pre-parse anyway. You can parse the HTML and then throw it away. The way things are setup where I work, our apache server talks to our HTML aggregation server via tcp/ip. The apache server serves static things like images, css, etc. But for HTML aggregation of search results, it forwards the request to the aggregation server, which makes a bunch of search requests and returns dynamically generated HTML... when we get a package of HTML and gifs and css from the design department, the first thing I have to do is copy the HTML file to the aggregation server and then make a .pm of it so that I can dynamically rewrite it at runtime. The gifs and css stay on the apache server. So, I could save myself something of a step if I could parse the HTML once, serialize it, and then clone it at runtime as necessary.


In reply to Re^2: fast return of HTML::Tree object clones (via threads/forks)? by metaperl
in thread fast return of HTML::Tree object clones (via threads/forks)? by metaperl

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.