Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re: How to read data from csv file and place the data on HTML format

by Tux (Abbot)
on Jun 27, 2013 at 06:55 UTC ( #1040927=note: print w/replies, xml ) Need Help??


in reply to How to read data from csv file and place the data on HTML format

Your parsing is unsafe and you are not returning html and you are printing references instead of fields

use Text::CSV; use HTML::Entities; sub ConvertData { my $csv = Text::CSV->new ({ binary => 1, auto_diag => 1 }); open my $fh, "<", $Filename or die "Couldn't open location file $F +ilename: $!"; my @report = ("<table>"); while (my $row = $csv->getline ($fh)) { push @report, "<tr>"; push @report, "<td>", encode_entities ($_), "</td>" for @$row; push @report, "</tr>"; } push @report, "</table>"; close $fh; return join "\n" => @report; }

Enjoy, Have FUN! H.Merijn
  • Comment on Re: How to read data from csv file and place the data on HTML format
  • Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (11)
As of 2016-12-06 18:07 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    On a regular basis, I'm most likely to spy upon:













    Results (113 votes). Check out past polls.