#!/local/bin/perl # # routine to create html tables from functional definitions # (i.e., a table generator) # $ncol = 20; $nrow = 13; $cstep = -2; # difference between columns (labelled on top) $rstep = 2; # difference between rows (labelled on LHS) $cval = 8; # initially, value at top of leftmost column $rval = 2; # initially, value at top of LHS label $cwidth = int( 100 / $ncol ); # round-down on col width. # may be no room left for LH label col $rem = 100 - $ncol * $cwidth; if ( $rem < 4 ) { $cwidth = $cwidth - 1; $rem = 100 - $ncol * $cwidth; } $twidth = 100 - $rem; # first, print titles and initial boilerplate # Mosaic will not support the CAPTION tag, so this is commented out, # and an H3 substituted. # Note that most of the cell WIDTH commands to not work to the degree expected, # and will likely need tuning for any particular table. print "

Table of Windchill Values for Various Temperatures and Windspeeds

\n"; print "\n"; # print "\n\n"; print "\n"; print "\t\n"; print "\t\n"; print "\n"; print "\n"; # print info for top row labelling. A column WIDTH is defined (necessary for # good Netscape presentation, but is somewhat successfully ignored by Mosaic browsers). $cv = $cval; for ( $i = 0; $i < $ncol; $i++ ) { print "\t\n"; $cv = $cv + $cstep; } print "\n"; # begin nested loops. do calculations in inner-most loop for ($j = 0; $j < $nrow; $j++ ) { # print LHS label, then do table data print "\n"; print "\t\n"; $cv = $cval; for ( $i = 0; $i < $ncol; $i++ ) { # $tval = 91.4 + ( $cv - 91.4 ) * ( .474 + .304 * ( $rval ** .5 ) - .0203 * $rval ); $tval = 33 + ( $cv - 33 ) * ( .474 + .454 * ( $rval ** .5 ) - .0454 * $rval ); printf "\t\n", $tval; $cv = $cv + $cstep; } print "\n"; $rval = $rval + $rstep ; } print "
Place table title here!
Windspeed (m/s) Air Temperature (degrees C)
$cv
$rval%3.0f
\n";