someone i know maintains a FAQ on multiple pages... does anyone know of a PERLscript that will allow hime to "concatenate" all of them into one (working) page?

(rather than just take what's given to me, i'll also write one off the top of my head please critique or write a better one)

# script requires an indexfile, with each # html filename to be concatenated in it # one html filename per line open(EACH_HTML_FILENAME,pagelist.txt) || die; open(UNIFIED_FILE,>>output.html) || die; # i could've used 'getopt' or @ARGV but this # is being written with brevity in mind ... # another thing i'd like to try to learn is # automatically geting a directorylist, parsing out # each filename with the extensions @ARGV and # concatenating them $first_pass = 1; while (<EACH_HTML_FILENAME>) { $thisfile = chomp($_); open(THIS_FILE,$thisfile) || die; if ($first_pass) { while (<THIS_FILE>) { if ($_ ne '</body>') { print{UNIFIED_FILE} "$_" ; } else { $first_pass = 0; # exit this iteration of the while loop } } } else { $body_start = 0; while (<THIS_FILE>) { if (!($body_start) { if ($_ eq '<body>) { $body_start = 1; } } else { if ($_ ne '</body>') { print{UNIFIED_FILE} "$_" ; } else { # exit this iteration of the while loop } # END -> if ($_ ne '</body>') } # END -> if (!($body_start) } # END -> while (<THIS_FILE>) } # END -> while (<EACH_HTML_FILENAME>) print{UNIFIED_FILE} "</body>" ;
anyways ... that's it, off the top of my head i think some criticism would help my coding skills and this utility (if it works) would help this guy i know (actually, it would also help me cause i want to be able to download a copy of his FAQ on one page ;)

In reply to html parse - concatenation by Buckaroo Buddha

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.