[5425] | 1 | #!/usr/bin/perl -w
|
---|
| 2 |
|
---|
| 3 | ###########################################################################
|
---|
| 4 | #
|
---|
| 5 | # splithelpdocument.pl
|
---|
| 6 | #
|
---|
| 7 | # A component of the Greenstone digital library software
|
---|
| 8 | # from the New Zealand Digital Library Project at the
|
---|
| 9 | # University of Waikato, New Zealand.
|
---|
| 10 | #
|
---|
| 11 | # Copyright (C) 1999 New Zealand Digital Library Project
|
---|
| 12 | #
|
---|
| 13 | # This program is free software; you can redistribute it and/or modify
|
---|
| 14 | # it under the terms of the GNU General Public License as published by
|
---|
| 15 | # the Free Software Foundation; either version 2 of the License, or
|
---|
| 16 | # (at your option) any later version.
|
---|
| 17 | #
|
---|
| 18 | # This program is distributed in the hope that it will be useful,
|
---|
| 19 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
| 20 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
| 21 | # GNU General Public License for more details.
|
---|
| 22 | #
|
---|
| 23 | # You should have received a copy of the GNU General Public License
|
---|
| 24 | # along with this program; if not, write to the Free Software
|
---|
| 25 | # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
---|
| 26 | #
|
---|
| 27 | ###########################################################################
|
---|
| 28 |
|
---|
| 29 |
|
---|
| 30 | sub main
|
---|
| 31 | {
|
---|
| 32 | local @lines = <STDIN>;
|
---|
| 33 |
|
---|
| 34 | local $filestart = 0;
|
---|
| 35 | local $filename = "";
|
---|
| 36 | for ($i = 0; $i < scalar(@lines); $i++) {
|
---|
| 37 | local $line = $lines[$i];
|
---|
| 38 |
|
---|
| 39 | if ($line =~ /\<a name=\"([^\"]+)\"\>/ && $filename eq "") {
|
---|
| 40 | $filename = $1;
|
---|
| 41 | }
|
---|
| 42 |
|
---|
| 43 | if ($line =~ /^\<html\>/ && $i > $filestart) {
|
---|
| 44 | open(FILE_OUT, ">$filename.htm") or die "Error: Could not write $filename.htm.\n";
|
---|
| 45 | for ($j = $filestart; $j < $i; $j++) {
|
---|
| 46 | print FILE_OUT $lines[$j];
|
---|
| 47 | }
|
---|
| 48 | close(FILE_OUT);
|
---|
| 49 |
|
---|
| 50 | $filestart = $i;
|
---|
| 51 | $filename = "";
|
---|
| 52 | }
|
---|
| 53 | }
|
---|
[6133] | 54 |
|
---|
| 55 | # Deal with the last file
|
---|
| 56 | if ($filename ne "") {
|
---|
| 57 | open(FILE_OUT, ">$filename.htm") or die "Error: Could not write $filename.htm.\n";
|
---|
| 58 | for ($j = $filestart; $j < $i; $j++) {
|
---|
| 59 | print FILE_OUT $lines[$j];
|
---|
| 60 | }
|
---|
| 61 | close(FILE_OUT);
|
---|
| 62 | }
|
---|
[5425] | 63 | }
|
---|
| 64 |
|
---|
| 65 |
|
---|
| 66 | &main(@ARGV);
|
---|