#!/usr/bin/perl -w my $table; my $hdrbreak; my $column; my @fields; my $numfields; my @row; my $lesson; $table = 0; $hdrbreak = 0; $column = 0; @row = (); # get the lesson number $lesson = ; chomp( $lesson ); # print the page head print "\n\n"; print '', "\n"; print '', "\n"; print '', "\n"; print "Derek"s Korean Vocabulary\n"; print "\n\n"; print '', "\n\n"; print '

Korean Vocabulary, ', $lesson, "

", "\n\n"; # process vocab list while (){ # start a new table, if needed if ( $table == 0 ){ print '', "\n"; $table = 1; } chomp; if ( ! $_ ){ # is this the end of a table, or only a header break? if ( $hdrbreak ){ # if there's already a header and a header break, this # is the end of a table, but we might need to print # the last row... if ( $column == 1 ){ @row = (@row, " ", " "); print ' \n"; print ' \n"; print ' \n"; print ' \n\n\n"; $column = 0; @row = (); } print "
'; print "$row[0]'; print "$row[1]'; print "$row[2]'; print "$row[3]
\n\n

\n\n"; $table = 0; $hdrbreak = 0; next; } # if there's a header, but no header break, headerbreak if ( ! $hdrbreak ){ $hdrbreak = 1; next; } } # now process the vocab # split on tab @fields = split " "; # if there's a header, but no header break, we need to print the # header in the table header if ( ! $hdrbreak ){ print '', "\n", ' '; print @fields; print "\n\n\n"; next; } # $field[0] is the Korean, and $field[n] is the English $numfields = @fields; @row = ( @row, $fields[0], $fields[$numfields - 1]); $column++; # print the table data if ($column == 2){ print "\n ", ''; print "$row[0]\n"; print ' '; print "$row[1]\n"; print ' '; print "$row[2]\n"; print ' '; print "$row[3]\n\n\n"; $column = 0; @row = (); } } # finish the page # if we forgot to end with a blank line if ( $column == 1 ){ @row = (@row, " ", " "); print ' '; print "$row[0]\n"; print ' '; print "$row[1]\n"; print ' '; print "$row[2]\n"; print ' '; print "$row[3]\n\n\n"; print "\n\n

\n\n"; $column = 0; @row = (); } print "\n\n\n";