in reply to I feel stupid... 2 hours later
I second 2teez's question about using a CSV module to parse your file. Given this, here's one option:
use strict; use warnings; use Text::CSV; my $csvFile = 'irregular-verbs.csv'; my $outFile = 'new.htm'; open my $outFH, '>', $outFile or die "Cannot open $outFile: $!"; my $csv = Text::CSV_XS->new( { binary => 1, auto_diag => 2 } ) or die "Cannot use CSV: " . Text::CSV->error_diag(); open my $csvFH, '<', $csvFile or die "Cannot open $csvFile: $!"; # $row contains an array reference to the parsed csv line's data while ( my $row = $csv->getline($csvFH) ) { print $outFH '<tr>'; print $outFH "<td>$_</td>" for @$row; print $outFH "<tr>\n"; } close $csvFH; close $outFH;
Output to file:
<tr><td>Base Form</td><td>Past Simple</td><td>Past Participle</td><td> +3rd Person Singular</td><td>Present Participle / Gerund</td><tr> <tr><td>Abide</td><td>Abode/Abided</td><td>Abode/Abided/Abidden</td><t +d>Abides</td><td>Abiding</td><tr> <tr><td>Aby/Abye</td><td>Abought</td><td>Abought</td><td>Abys/Abyes</t +d><td>Abying</td><tr> <tr><td>Alight</td><td>Alit/Alighted</td><td>Alit/Alighted</td><td>Ali +ghts</td><td>Alighting</td><tr> <tr><td>Arise</td><td>Arose</td><td>Arisen</td><td>Arises</td><td>Aris +ing</td><tr> <tr><td>Awake</td><td>Awoke</td><td>Awoken</td><td>Awakes</td><td>Awak +ing</td><tr>
Hope this helps!
|
|---|