#!/usr/local/bin/perl # # Arnaud Le Hors - lehors@w3.org # $Id: htmlcat,v 1.1 1997-07-29 17:14:49 ijacobs Exp $ $PROGNAME = substr($0, rindex($0, "/") + 1); if (!$ARGV[0]) { print "Usage: $PROGNAME output file1 file2 ...\n"; exit 1; } open(OUTPUT, "> $ARGV[0]"); shift; # copy file in memory sub readfile { $buf = ""; if (!open(INPUT, $_[0])) { print STDERR "$PROGNAME Error: Cannot open file: $_[0]\n"; return; } while () { $buf .= $_; } close(INPUT); } # 1st file: take everything up to the body end tag or the end otherwise readfile($ARGV[0]); $_ = $buf; if (/<\/body>/sio) { print OUTPUT $`; } else { print OUTPUT $buf; } shift; # then for each other given html file only take the body content foreach $file (@ARGV) { readfile($file); # look for the beginning of the body content $_ = $buf; if (/(.*)/sio) { $buf = $1; } elsif (/<\/head>/sio) { $buf = $'; } # look for the end of the body content $_ = $buf; if (/<\/body>/sio) { print OUTPUT $`; } elsif (/<\/html>/sio) { print OUTPUT $`; } else { print OUTPUT $buf; } } # close body print OUTPUT "\n"; close(OUTPUT);