#! c:/perl/bin/perl
#
# csv2html2.cgi
# csvファイルをHTMLのTABLE表示する。
# Convert CSV file to TABLE format of HTML.
#
# 1.00 : 6/29/06 : Initial revisoin
#
# $Id: csv2html2.cgi,v 1.2 2006/06/30 03:14:10 Hideki Kanayama Exp $
# Copyright(c) 2005-2006, Hideki Kanayama All rights reserved.
#
use CGI::Carp qw(fatalsToBrowser);
use strict;
my $csvfile = "csvfile.csv";
print "Content-Type: text/html\n\n";
my $max = 0;
my $row = 0;
my @td;
if (open (CSV, "< $csvfile")) {
while (){
my @cols = split(/,/);
if ($#cols > $max) {
$max = $#cols;
}
$td[$row++] = "$_";
}
close CSV;
}
print "\n";
my $i;
my $j;
my $colline;
foreach (@td){
chomp;
my @cols = split(/,/);
print "\n";
for ($colline=0;$colline<=$max;$colline++){
if ($cols[$colline] eq '') {$cols[$colline] = " "}
print "| $cols[$colline] | \n";
}
print "
\n\n";
}
print "
\n";