
sabercats
Novice
Nov 16, 2012, 3:59 PM
Post #1 of 4
(3703 views)
|
Insert flatline fiels into html table
|
Can't Post
|
|
Hi all, I have flatfile A.txt 4 fields Date|Product|Notes|Location so i use myperl.pl to read data as html table as below
#!/usr/bin/perl #print "content-type: text/html\n\n"; use warnings; #################################################################################################### open (DATA,"/mylogs/list.log") || die ("Can't Open data File \n"); @data=<DATA>; close DATA; &header_response; foreach $line (@data) { $x++; ($date, $product,$notes,$location)=split(/\|/,$line); { print "<TD BGCOLOR='F5F5F5'>$date</TD><TD BGCOLOR='F5F5F5'>$product</TD><TD BGCOLOR='F5F5F5'>$note</TD><TD BGCOLOR='F5F5F5'>$location</TD></TR> \n"; } } &footer_response; sub header_response { print "Content-type: text/html\n\n"; print "<HTML><HEAD><TITLE>Testing</TITLE>\n"; print "</HEAD>\n"; print "<center><FONT size=+1><TABLE BORDER=3><TR bgcolor=#33FFCC><TD><center><font color=white>Date</center></TD><TD><center><font color=white>Product</center></TD><TD><center><font color=white>Notes</center></TD><TD><center><font color=white>Location</center></TD></TR>\n\n"; return; } sub footer_response { print "</TABLE></font></CENTER>\n"; print "<BR><BR>\n"; print " </BODY></HTML>\n"; return; } Now how you can write it so it will create multiple tables based on location? Ex:
<H2>$location</h2> <table border="1" bordercolor="#FFCC00" style="background-color:#FFFFCC" width="100%" cellpadding="3" cellspacing="3"> <tr> <td>Date</td> <td>Product</td> <td>Note</td> </tr> <tr> <td>$date</td> <td>$product</td> <td>$note</td> </tr> </table> Thanks for your help
|