Multiple records in rows
Hi I have a partial solution working to show so many records in a row.
How to make it work so only, say, 2 rows show - I don't know how to do.
file.txt
Perl script
I also don't want to use a module for this (can't understand most of them anyways).
Please can someone help.
Thanks beforehand
Hi I have a partial solution working to show so many records in a row.
How to make it work so only, say, 2 rows show - I don't know how to do.
file.txt
Code:
01|Aaaa| 02|Bbbb| 03|Cccc| 04|Dddd| 05|Eeee| 06|Ffff| 07|Gggg| 08|Hhhh| 09|Iiii| 10|Jjjj| 11|Kkkk| 12|Llll|
Code:
use strict;
use warnings;
use CGI::Carp qw(warningsToBrowser fatalsToBrowser);
print "Content-type: text/html\n\n";
my $file="file.txt";
my $num="3";
my $rw="2"; ## this will be for number of rows shown
my $pt="1";
# Don't like the foreach, but couldn't get while loop to do this.
open(INF,"$file") or die("Can't open $file: $!"); my @md = <INF>; close(INF);
print qq ~<table border="1"><tr>~;
foreach my $line (@md) {chomp($line);
my @fd=split /\|/, "$line";
if ($pt == $num) {
print "<td>$fd[0]</td><td>$fd[1]</td></TR><TR>\n"; $pt=1;
}
else
{
if ($fd[0] ne "") {print "<td>$fd[0]</td><td>$fd[1]</td>\n"; $pt++;
}
}
}
print qq ~</tr></table>~;
exit(0);
Please can someone help.
Thanks beforehand
Comment