Note that there are some explanatory texts on larger screens.

plurals
  1. POHow Create Html Table from formatted text file
    primarykey
    data
    text
    <p>As subject, I have to write a perl script that transforms a log file like:</p> <pre><code>pippo 2 64 0 2 pippo_a 3 24 0 2 Pippo_b 2 60 0 23 pluto 0 18 0 4 pluto_a 8 25 0 6 paperino 0 11 1 7 paperino_a 0 27 0 10 coyote 0 29 0 7 beepbeep 0 1 0 0 tommy 3 31 0 27 paperone 4 43 1 15 paperone_a 4 52 0 13 benjamin 0 21 1 35 paperina 10 0 0 0 papera 0 0 0 0 quiquoqua 3 26 0 17 quiquoqua_a 3 25 0 3 pochaontas 0 12 0 68 minnie 11 60 3 384 </code></pre> <p>In this html table format:</p> <p>LINK: <a href="http://imageshack.us/a/img90/7238/tabellao.jpg" rel="nofollow noreferrer">http://imageshack.us/a/img90/7238/tabellao.jpg</a></p> <p>Now I have write this little perl script, but I've problem to create the write cycle, from the @cells array:</p> <pre><code>#! /usr/bin/perl print "Content-type:text/html\r\n\r\n"; use CGI qw(:standard); use strict; use warnings; use DateTime; my $line; my $file; $file='loggi.txt'; open(F,$file)||die("Could not open $file"); print "&lt;html&gt;\n &lt;style type='text/css'&gt;\n body {\n font-family: Verdana, Arial, Helvetica, sans-serif;\n color: #333;\n }\n table {\n font-size:11px;\n }\n td#vtl, td#pool {\n font-weight: bold;\n writing-mode: bt-rl;\n #-webkit-transform: rotate(90deg);\n #-moz-transform: rotate(90deg);\n #-ms-transform: rotate(90deg);\n #-o-transform: rotate(90deg);\n #transform: rotate(90deg);\n }\n .zone tr{\n border:2px dotted black;\n }\n &lt;/style&gt;\n &lt;body&gt;\n &lt;table border=2&gt;\n &lt;!--Intestazione--&gt;\n &lt;tr&gt;\n &lt;th id='vtl'&gt;houses&lt;/th&gt;\n &lt;th id='pool'&gt;id&lt;/th&gt;\n &lt;th id='host'&gt;name&lt;/th&gt;\n &lt;th id='vergini'&gt;Ver.(*)&lt;/td&gt;\n &lt;th id='riciclabili'&gt;(yes)&lt;/th&gt;\n &lt;th id='vuote'&gt;zero&lt;/th&gt;\n &lt;th id='full'&gt;Full&lt;/th&gt;\n &lt;th id='spazi'&gt;space&lt;/th&gt;\n &lt;/tr&gt;\n &lt;!--Corpo--&gt;\n &lt;!--VTLA--&gt;"; print "&lt;tr align='center'&gt;\n &lt;td id='case' rowspan=7&gt;casaa&lt;/td&gt;\n &lt;td id='id' rowspan=7&gt;10&lt;/td&gt;\n &lt;th id='a' colspan=5&gt;pippi&lt;/th&gt;\n &lt;td id='space' rowspan=30&gt;0&lt;/td&gt;\n &lt;/tr&gt;"; while ($line=&lt;F&gt;) { print "&lt;tr&gt;"; my @cells= split ' ',$line; foreach my $cell (@cells) { if $cell == 'pippo' { print "&lt;td id='name'&gt;$cell&lt;/td&gt;"; print "&lt;td id='a'&gt;$cell&lt;/td&gt;"; print "&lt;td id='b'&gt;$cell&lt;/td&gt;"; print "&lt;td id='c'&gt;$cell&lt;/td&gt;"; print "&lt;td id='d'&gt;$cell&lt;/td&gt;"; }} print "&lt;/tr&gt;"; } close(F); print "&lt;/table&gt;\n &lt;br/&gt;\n Situazione aggiornata al".DateTime-&gt;now()-&gt;strftime("%a, %d %b %Y %H:%M:%S %z")." &lt;/body&gt;\n &lt;/html&gt;"; </code></pre> <p>This is my first long perl script, can someone help me in reasoning?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload