#!/usr/local/bin/perl
#
# parg2html.pl
#
# This script turns the input file with paragraphs of text separated by newlines
# into files named pattern.##.html one paragraph per file
# Run "program -h" to see the run options
#
# Last modified: 9/16/96
# Author: Bekman Stas
#
$0 =~ s/^.*\///; # cut the basename of the command
# Diagnostic part...
if ($#ARGV<1 || $h) {
die "\nUsage:
\t $0 [-options] pattern input_file
options:
-h You read me now
pattern to create pattern.##.html
input_file file with paragraphs separated by one or more newlines
\n";
}
$pref=$ARGV[0];
$infile=$ARGV[1];
open (IN, "$infile") || die "Can't open $infile: $!\n";
$buffer=0;
$counter=0;
while(){
if (/^[^a-zA-Z0-9]+$/)
{$newline=1;}
else {
$buffer++;
$newline=0;
@parg=(@parg,$_);
}
if ($newline && $buffer) {
$counter++;
open(HTML, ">$pref.$counter.html") || die "Can't open $pref.$counter.html: $!\n";
print HTML @parg;
$newline=0;
$buffer=0;
@parg="";
close HTML;
}
}
close IN;