Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

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!


Comment on Re: I feel stupid... 2 hours later
Select or Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1005340]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (14)
As of 2014-07-30 11:49 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (230 votes), past polls