Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot

Re: I feel stupid... 2 hours later

by Kenosis (Priest)
on Nov 24, 2012 at 07:37 UTC ( #1005340=note: print w/replies, xml ) Need Help??

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!

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1005340]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (3)
As of 2018-03-22 02:51 GMT
Find Nodes?
    Voting Booth?
    When I think of a mole I think of:

    Results (272 votes). Check out past polls.