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

Hi, I'm brand new to perl progmam.I have a data pulled from a query the data looks like 1,05/05/2017 6:00:00PM, Harsha, 23457585, Kundeti. 8 rows of data in the same format. I'm storing this data in a $outdata . variable which is being pulled from a while loop. I have used the html EOI method to populate. When i have passed hte $outdata to the table all the rows are being populated in hte same line. my requirement is to print the data one after the other with a line. How to run a loop to fetch the data by line by line? THanks, harsha
  • Comment on How to copy data pulled from a sql query into a HTML Table

Replies are listed 'Best First'.
Re: How to copy data pulled from a sql query into a HTML Table
by NetWallah (Canon) on May 09, 2017 at 01:04 UTC
    You can use the CGI module to generate HTML tables.

    I have not heard of the "EOI method" - not sure that is relevant here.

    If you show us some code, we can help improve it.

            ...Disinformation is not as good as datinformation.               Don't document the program; program the document.

Re: How to copy data pulled from a sql query into a HTML Table
by AnomalousMonk (Archbishop) on May 09, 2017 at 03:46 UTC
Re: How to copy data pulled from a sql query into a HTML Table
by LanX (Saint) on May 09, 2017 at 00:07 UTC
Re: How to copy data pulled from a sql query into a HTML Table
by tobyink (Canon) on May 09, 2017 at 10:34 UTC

    This is concise, but don't do it this way — I was just challenging myself to output the entire table in one print statement using no pesky variables. Fetching one row at a time is more memory efficient if your table has more than a few rows.

    use strict; use warnings; use DBI; use Data::Dumper; use HTML::Entities qw/encode_entities/; my $dbh = DBI->connect('DBI:SQLite:', undef, undef, { RaiseError => !! +1 }); $dbh->do($_) for split /;;/, <<'GO'; CREATE TABLE example ( id integer, name varchar, age integer, PRIMARY KEY(id) );; INSERT INTO example VALUES (1, 'Alice', 25);; INSERT INTO example VALUES (2, 'Bob', 26);; INSERT INTO example VALUES (3, 'Carol', 24);; INSERT INTO example VALUES (4, 'Dave', 25);; INSERT INTO example VALUES (5, 'Eve', 666);; GO my $sth = $dbh->prepare('SELECT * FROM example'); $sth->execute(); print( "<table>\n". "\t<thead>\n". "\t\t<tr>".join('', map sprintf('<th>%s</th>', encode_entities($_) +), @{$sth->{NAME_lc}})."</tr>\n". "\t</thead>\n". "\t<tbody>\n". join("\n", map sprintf( "\t\t<tr>%s</tr>", join '', map sprintf('<td>%s</td>', encode_entities($_)), +@$_ ), @{ $sth->fetchall_arrayref })."\n". "\t</tbody>\n". "</table>\n" );
Re: How to copy data pulled from a sql query into a HTML Table
by Anonymous Monk on May 09, 2017 at 01:53 UTC
Re: How to copy data pulled from a sql query into a HTML Table
by Anonymous Monk on May 09, 2017 at 17:26 UTC