chandchv has asked for the wisdom of the Perl Monks concerning the following question:

I have to split html pages into separate components and save them as .shtml on the fly using perl and push to the server folders where the apache can pick them up and generate html ......... how can i do that ? Could someone give me some suggestions or atleast some small snippets of perl that i can use Thanks in advance

Replies are listed 'Best First'.
Re: I want to Split html pages
by GrandFather (Saint) on Nov 12, 2008 at 09:15 UTC

    You may find HTML::TreeBuilder is helpful in rendering chunks of HTML from an HTML document.


    Perl reduces RSI - it saves typing
Re: I want to Split html pages
by moritz (Cardinal) on Nov 12, 2008 at 08:15 UTC
    How can you do that? Step by step.

    In the beginning you have to find some rules on how to split your HTML files. Surely you don't want to do that completely randomly, but in way that makes sense for your application.

    The tools for splitting strongly depend on the splitting criteria, so we really can't recommend anything useful without knowing these criteria.

      Hi Moritz, I have to add certian place holders on top of the components in the page so that my perl knows where to start and where to end extracting the htm snippet, they would be replaced by tag ssi includes for that snippet in the body of the page, after extraction of the components so that the Apache can process those snippets. but my problem is how to dynamicaly extract those snippets and save them in different files thanks again
        You can probably search and replace with regular expressions. Or you can split it into pieces. But how exactly that works depends on how your markers look like.

        Since you didn't provide any sample data but just a hand-waving description, the answer can only be equally hand-waving.