#!/usr/bin/perl -w

use strict;
use warnings;

use File::Basename;
use Getopt::Std;

my %opt;
my @suffix = ('.txt');

opendir (TMPDIR, ".") or die "Error open dir [".$!."]\n";

my @aTextFiles
    = grep { 
            /(\.txt)$/i             # Ends with ppm or pbm
            && -f "$_"   # and is a file
    } readdir(TMPDIR);

print "<HTML>\n<BODY>\n";
foreach  my $file (sort @aTextFiles){
    next unless -f "$file";
    open TXTFILE, "< $file";
    my $bParagraphFlag=0;
    while (<TXTFILE>){
        chomp $_;
#    system("cat", "$file");

# ############ END TURN ON PARAGRAPHS 
        if (/[."!?)]{1,2}$/){
            print $_."<br>\n";
			next;
		}elsif(length ($_) < 60){
			my $testForSpace = $_;
			$testForSpace =~ s/\s//g;

			if (length ($testForSpace) > 1){
            	print $_."<br>\n";
			}

			next;
		}

# ############ END TURN ON PARAGRAPHS 

        s/^\s*(\(|\))//;
        print $_."\n" unless (/^\s*\d+\s*$/);
        print STDERR "SKIPPING TXT [".$_."]\n" if (/^\s*\d+\s*$/);
    }
#    print "<HR>\n";
}
print "</BODY>\n</HTML>\n";
