There are lots of ways to optimize this, but it works now. That'll be $250 for an hour of my time.#!/usr/bin/perl -w use strict; my $file = shift || die "usage: $0 <text file>\n"; my @rows; my @temprows; my @header; local *INPUT; open (INPUT, $file) || die "$!\n"; my $first = 0; while(<INPUT>) { chomp; push @temprows, split /[ \']+/; my @row; while (@temprows) { if ($first == 0) { push @header, shift @temprows; push @row, shift @temprows; } else { shift @temprows; push @row, shift @temprows; shift @temprows; push @row, shift @temprows; } } $first = 1; push @rows, [ @row ]; } close INPUT; my $html = "<table><tr>\n"; foreach (@header) { $html .= "<td>$_</td>\n"; } foreach (@rows) { $html .= "<tr>"; foreach (@$_) { $html .= "<td>$_</td>"; } $html .= "</tr>\n"; } $html .= "</table>\n"; print $html;
In reply to Re: Code request
by chromatic
in thread Code request
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |