====== A Perl script to transform CSV fields into HTML rows and cells ====== #!/usr/bin/perl # csv4-rows.pl - prepare csv for HTML table use strict; use warnings; use Text::CSV; use File::Slurp 'read_file'; use CGI; my $q = new CGI; # my $file = 'jp4w4-l.csv'; my $croala = "http://www.ffzg.unizg.hr/klafil/croala/cgi-bin/search3t?dbname=croala&OUTPUT=TF&word="; my $panon = "http://www.ffzg.unizg.hr/klafil/croala/cgi-bin/search3t?dbname=croala&OUTPUT=TF&author=panonij&word="; my $file = shift or die 'filename!'; my $csv = Text::CSV->new(); open(CSV, '<', $file) or die "Could not open '$file' $!\n"; while () { my $broj = $. ; if ($csv->parse($_)) { my @columns = $csv->fields(); print $q->Tr($q->td([$broj . ".", $columns[0], $columns[1]]), $q->td({align=>"RIGHT"}, $q->b($columns[3])), $q->td([" ", $q->a({ href => $panon . $columns[1]}, "Pannonius")]), $q->td({align=>"RIGHT"}, $q->b($columns[5])), $q->td([" ", $q->a({ href => $croala . $columns[1]}, "CroALa")])), "\n"; } else { my $err = $csv->error_input; print "Failed to parse line: $err"; } }