#!/usr/bin/perl -w # # $Id: eztable,v 1.4 2007/08/29 22:54:37 vogelke Exp $ # #) || die "no title"; chomp($_ = <>) || die "no columns"; @cols = split(/\t/); # Store the remainder of the file. We could do # line-at-a-time processing, but we might want to simply # pass everything to a template. while (<>) { chomp; push(@rest, $_); } # Print the HTML header, title, and table start. print <<"EndHeader"; $title

$title

EndHeader print " \n"; foreach (@cols) { print " \n"; } print " \n"; # Print the main table entries. foreach (@rest) { print "\n"; foreach (split(/\t/)) { $_ = htmlsafe($_); print " \n"; } print "\n"; } # Print the footer. my $adate = arpadate(time()); my @v = split(/\s+/, version()); print <<"EndFooter";
$_
$_

EndFooter exit(0); #--------------------------------------------------------------------- # Escape non-HTML-safe characters. sub htmlsafe { my $text = $_[0]; return undef unless defined $text; # do it in this order, or you get lots of &... $text =~ s/\&/&/g; $text =~ s/>/>/g; $text =~ s/