Another method of this script would be like this:
This is a quick and dirty script which assumes that the body tags are alone on the line (or at least that there is nothing there that should be preserved in the final version.)$flip=1; while(<>){ $flip=0 if /<\/body/i; print $_ if $flip; $flip=1 if /<body/i; } print "</body>\n</html>\n";
It would be called like "faqcat.pl file1.html file2.htrml filen.html > newfile.html
(Should work in both UNIX and Win/DOS)
The next step is making sure that any internal links work correctly. If the files are merely text (i.e. non-linking HTML) this will be enough, but probably it has internal links to Table of contents, and different sections. I can't say how to correct those, because a lot depends on how the files are written, but if the syntax is simple, you can do it with Regex's, if it is more complex, you can do it with HTML::Parser.
Update: Some explanation on how the script works:
The idea is that we want to print everything that is not following a /BODY and not before a BODY, but we do want to print the stuff before the first BODY.
The <> automagically brings the next line from any file(s) on the command-line. see perlop.
In reply to Re: html parse - concatenation
by swiftone
in thread html parse - concatenation
by Buckaroo Buddha
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |