#!/usr/local/bin/perl # chdir "/opt/html"; open(COMPOUNDS, ">compounds.html") or die "Can't open compounds.html"; open(BLOCKS, ">blocks.html") or die "Can't open blocks.html"; open(BLOCKLIST, ">blocklist.html") or die "Can't open blocklist.html"; open(DETAIL, ">blank.html") or die "Can't open blank.html"; print BLOCKS "\n\n\n
\n";
print BLOCKS "  NAME          TYPE    DESCRP                            PER PHASE\n";
print BLOCKS "-------------------------------------------------------------------\n";
print BLOCKLIST "\n\n\n
\n";
print BLOCKLIST "BLOCK LIST\nBLOCK         COMPOUND      TYPE\n----------------------------------\n";
print COMPOUNDS "\n\n\n\nCOMPOUND LIST:
\n--------------\n
"; print DETAIL "\n\n\n
\n";
$z = -1;

while (<*.prt>) {
   $INFILE = $_;
   print "processing $INFILE\n\n";
   open(INFILE) or die "Can't open $INFILE: $!\n";
   $x = -1;
   while (defined ($line = )) {
      $x++;
      chomp ($line);
      $block[$x] = $line;
      @record = split(/\s+= /, $line, 2);
      if ( $record[0] eq "NAME" ) {
         $z++;
         $name = $record[1];
         $compound = $name;
         if ( $name =~ /^(.*):(.*)$/) {
            $name = $2;
            $compound = $1;
         }
         $build = sprintf("  %-14s", $name);
         $block[$x] = sprintf("\n%-45s", $line);
         $bn = sprintf("%-12s", $name);
         $cn = sprintf("%-14s", $compound);
         $block_list[$z] = "$bn  $cn";
      } elsif ( $record[0] eq "  TYPE" ) {
         $build = $build . sprintf("%-8s", $record[1]);
         $block_list[$z] = $block_list[$z].$record[1];
         if ($record[1] =~ /COMPND/) {
            print DETAIL "
\n\n"; close(DETAIL); open(DETAIL, ">c_$compound.html") or die "Can't open c_$compound.html"; print DETAIL "\n\n\n
\n";
            print BLOCKS "\n$name:COMPOUND\n---------------------\n";
            print COMPOUNDS "$name
\n"; } } elsif ( $record[0] eq " DESCRP" ) { $build = $build . sprintf("%-34s", $record[1]); } elsif ( $record[0] eq " PERIOD" ) { $build = $build . sprintf("%-4s", $record[1]); } elsif ( $record[0] eq " PHASE" ) { $build = $build . sprintf("%-6s", $record[1]); } elsif ( $line =~ /^(.*) = (.*):(.*)\.(.*)$/ ) { $n = $1; $c = $2; $b = $3; $cb = "$2:$3"; $bp = "$cb.$4"; if ( $cb =~ /^:/ ) { $c = $compound; } $block[$x] = sprintf("$n = %-34s", $bp); # print "$n --- $cb --- $fullcb -- $compound -- $padded\n"; } elsif ( $record[0] eq "END" ) { $build = "$build" . "\n"; print BLOCKS $build; $block[$x] = " END"; $rows = int( @block/2 + 0.6 ); for ( $i = 0; $i < $rows; $i++ ) { printf(DETAIL "%-45s%-45s\n", $block[$i], $block[$i+$rows]); } @block = (); $x = -1; } else { } } close INFILE; } print BLOCKS "
\n\n"; @sorted_block_list = sort @block_list; foreach $i (@sorted_block_list) { print BLOCKLIST "$i\n"; } print BLOCKLIST "
\n\n"; print COMPOUNDS "\n"; print DETAIL "
\n\n"; close COMPOUNDS; close BLOCKS; close BLOCKLIST; close DETAIL;