Confused has asked for the wisdom of the Perl Monks concerning the following question:

This node falls below the community's threshold of quality. You may see it by logging in.

Replies are listed 'Best First'.
Re: Converting Text Files
by mirod (Canon) on Apr 07, 2001 at 02:13 UTC

    The short answer would be something like this:

    #!/bin/perl -w use strict; print "<html><head><title>Table</title></head>\n"; print qq{<body><table border="1">\n}; while( <DATA>) { print '<tr><td>'; print join '</td><td>', split /\|/; print "</td></tr>"; } print '</table></body></html>'; __DATA__ row 1 | 1 | 2 row 2 | 1 | 2 row 3 | 1 | 2

    But if you want to write anything serious you should look at DBI, DBD::RAM or DBD::CSV and CGI.

Re: Converting Text Files
by tinman (Curate) on Apr 07, 2001 at 02:09 UTC

    You might want to check this node for some sample code.

    You might also want to look at CPAN modules suggested by earlier posters in the same thread, specifically, CGI.pm, DBD::CSV

    If you want something a little bit fancier, XML::CSV might be what you're looking for...
    HTH

Re: Converting Text Files
by tadman (Prior) on Apr 07, 2001 at 02:15 UTC
    You might want to put it into tables, in which case it's pretty easy:
    print "<TABLE>\n"; while (<FILE>) { chomp; print "<TR>", (map { $_ =~ s/</&lt;/g; "<TD>$_</TD>" } split (/\|/)), "</TR>\n"; } print "</TABLE>\n";
    Note: Don't forget to convert '<' to the HTML-safe equivalent '&lt;' before printing the HTML.
Re: Converting Text Files
by voyager (Friar) on Apr 07, 2001 at 07:58 UTC