David Allender wrote:
>
> Hey all,  Ive been searching around the net and the web and can't
> really find anything, so here goes...
> 
> I'm in sort of a dilemma, what I have is a HTML file "archive.html"
> and a "build.html"
> what i want to do, is get the body of the "build.html" and put it
> where the body starts in "archive.html".  Anyone have any ideas of
> creating a script to do this?

Something like this perhaps?

use strict;
use warnings;

open my $archive, '<', 'archive.html' or die $!;

open my $merge, '>', 'merge.html' or die $!;

while (<$archive>) {

  if (/(.*<body>)(.*)/i) {
    print $merge "$1\n";
    open my $build, '<', 'build.html' or die $!;
    print $merge $_ while <$build>;
    s/^\s+//, s/\s+$// for my $suffix = $2;
    print $merge "$suffix\n" if $suffix;
  }
  else {
    print $merge $_;
  }
}

> Also,
> 
> Would there be a way for me to postpend "archive.html" to another page
> like "form.html".  Basically the archive has all the previous
> instances of the form, and for the user to see the previous ones, they
> just scroll down(after the submit button) and see the previous
> "forms". I'd appreciate any help, thanks.

I'm not sure what you mean, but it sounds like a technique similar to the one I
used above would do it for you. Alternatively you could open form.html for
append, like this

  open my $fh, '>>', 'form.html' or die $!;

and everything that is printed to $fh will be added to the end of the file.

HTH,

Rob


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/


Reply via email to