View Single Post
Old 01-20-2013, 04:00 PM   #7
dgatwood
Curmudgeon
dgatwood ought to be getting tired of karma fortunes by now.dgatwood ought to be getting tired of karma fortunes by now.dgatwood ought to be getting tired of karma fortunes by now.dgatwood ought to be getting tired of karma fortunes by now.dgatwood ought to be getting tired of karma fortunes by now.dgatwood ought to be getting tired of karma fortunes by now.dgatwood ought to be getting tired of karma fortunes by now.dgatwood ought to be getting tired of karma fortunes by now.dgatwood ought to be getting tired of karma fortunes by now.dgatwood ought to be getting tired of karma fortunes by now.dgatwood ought to be getting tired of karma fortunes by now.
 
Posts: 311
Karma: 1028382
Join Date: Jan 2012
Device: iPad, iPhone, Nook Simple Touch
If you have a Perl interpreter, you could do something like this:

Code:
#!/usr/bin/perl

$/ = undef;

my $filename = $ARGV[0];

open(INPUT, "<$filename");
my $data = <INPUT>;
close(INPUT);

my @parts = split(/<splitmarker>/, $data);

my $count = 1;
for my $part (@parts) {
    open(OUTPUT, ">outfile_$count.html");
    print OUTPUT $part;
    close(OUTPUT);
    $count++;
}
Save it as split.pl, change "<splitmarker>" to match what you're splitting on, change the output filename if you want (currently outfile_1.html, outfile_2.html, .. outfile_n.html), and then run "split.pl mybook.html" or whatever.

You'll want to then go back and add the starting and ending <html> tags, <head> tags, etc. from the first file to each of the other files.
dgatwood is offline   Reply With Quote