ronan_40060
asked on
displaying result in a specific table format
The following is the required perl code which displays the result
print "<table align=\"center\" bgcolor=\"#f5deb3\" border=2 bordercolor=\"maroon\">";
print "<tr>";
print "<td>";
while (<FILE>) {
next unless /$date/i;
print "<b>Date: $1 $2\n</b>" if /Date:.{4}(.{6}).{10}(.{4} )/;
print"<br>";
if (my ($xml, $x_pdf, $x_reussite) = /XML:(\d+)[^:]+:(\d+)[^:]+ :\s*([^\n] +)/i)
{
printf "Nombre de XML: $xml<br>\nNombre de PDF(xml):$x_pdf<br>\nPourc entage de réussite:%.1f",$x_reussite ;
}
print "<br>";
print "\n----------------------- ---------- ---------\ n";
print "<br>";
if (my ($doc, $d_pdf, $d_reussite) = /DOC:(\d+)[^:]+:(\d+)[^:]+ :\s*([^\n] +)/i)
{
printf "Nombre de DOC: $doc<br>\nNombre de PDF(doc):$d_pdf<br>\nPourc entage de réussite:%.1f",$d_reussite ;
}
last;
print "<br>";
print "<br>";
}
print "</td>";
print "</tr>";
close FILE;
print "</table>";
the above script displays the result in the following format
Date: Dec 12 2002
Nombre de XML: 224
Nombre de PDF(xml):204
Pourcentage de réussite:91.1
-------------------------- ---------- ------
Nombre de DOC: 27
Nombre de PDF(doc):27
Pourcentage de réussite:100.0
-------------------------- ---------- ---------- ---------- ---------- ---------- ---------- -
I need to display the same result above into the following table format
-------------------------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ----------
|Date | No XML | Nb XML (pdf) | % reussite | Nb Doc | Nb DOC(pdf)| % reussite |
-------------------------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ----------
|Dec 12 2002 | 224 | 204 | 91.1 | 27 | 27 | 100.0 |
-------------------------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- -------
What changes are to be made in the given perl script ?
print "<table align=\"center\" bgcolor=\"#f5deb3\" border=2 bordercolor=\"maroon\">";
print "<tr>";
print "<td>";
while (<FILE>) {
next unless /$date/i;
print "<b>Date: $1 $2\n</b>" if /Date:.{4}(.{6}).{10}(.{4}
print"<br>";
if (my ($xml, $x_pdf, $x_reussite) = /XML:(\d+)[^:]+:(\d+)[^:]+
{
printf "Nombre de XML: $xml<br>\nNombre de PDF(xml):$x_pdf<br>\nPourc
}
print "<br>";
print "\n-----------------------
print "<br>";
if (my ($doc, $d_pdf, $d_reussite) = /DOC:(\d+)[^:]+:(\d+)[^:]+
{
printf "Nombre de DOC: $doc<br>\nNombre de PDF(doc):$d_pdf<br>\nPourc
}
last;
print "<br>";
print "<br>";
}
print "</td>";
print "</tr>";
close FILE;
print "</table>";
the above script displays the result in the following format
Date: Dec 12 2002
Nombre de XML: 224
Nombre de PDF(xml):204
Pourcentage de réussite:91.1
--------------------------
Nombre de DOC: 27
Nombre de PDF(doc):27
Pourcentage de réussite:100.0
--------------------------
I need to display the same result above into the following table format
--------------------------
|Date | No XML | Nb XML (pdf) | % reussite | Nb Doc | Nb DOC(pdf)| % reussite |
--------------------------
|Dec 12 2002 | 224 | 204 | 91.1 | 27 | 27 | 100.0 |
--------------------------
What changes are to be made in the given perl script ?
oops, if using strict
Comment from cjmos
Date: 05/03/2004 07:51PM BST
Your Comment
ronan_40060
I havn't had time to test this but try altering the above to:
######################
print "<table align=\"center\" bgcolor=\"#f5deb3\" border=2 bordercolor=\"maroon\">";
print "<tr>";
print "<td>";
print "Date</td><td>No XML</td><td>Nb XML (pdf)</td><td>% reussite</td><td>Nb Doc</td><td>Nb DOC(pdf)</td><td>% reussite</td></tr>";
while (<FILE>) {
next unless /$date/i;
my $dateStr = "<b>Date: $1 $2\n</b>" if /Date:.{4}(.{6}).{10}(.{4} )/;
if ((my ($doc, $d_pdf, $d_reussite) = /DOC:(\d+)[^:]+:(\d+)[^:]+ :\s*([^\n] +)/i) && (my ($xml, $x_pdf, $x_reussite) = /XML:(\d+)[^:]+:(\d+)[^:]+ :\s*([^\n] +)/i))
{
printf "<tr><td>$dateStr</td><td> $xml</td>< td>$x_pdf< /td><td>%. 1f</td><td >$doc</td> <td>$d_pdf </td><td>% .1f",$x_re ussite,$d_ reussite;
}
last;
}
print "</td>";
print "</tr>";
print "</table>";
close FILE;
########################## #
Comment from cjmos
Date: 05/03/2004 07:51PM BST
Your Comment
ronan_40060
I havn't had time to test this but try altering the above to:
######################
print "<table align=\"center\" bgcolor=\"#f5deb3\" border=2 bordercolor=\"maroon\">";
print "<tr>";
print "<td>";
print "Date</td><td>No XML</td><td>Nb XML (pdf)</td><td>% reussite</td><td>Nb Doc</td><td>Nb DOC(pdf)</td><td>% reussite</td></tr>";
while (<FILE>) {
next unless /$date/i;
my $dateStr = "<b>Date: $1 $2\n</b>" if /Date:.{4}(.{6}).{10}(.{4}
if ((my ($doc, $d_pdf, $d_reussite) = /DOC:(\d+)[^:]+:(\d+)[^:]+
{
printf "<tr><td>$dateStr</td><td>
}
last;
}
print "</td>";
print "</tr>";
print "</table>";
close FILE;
##########################
ASKER
thanks cjmos
I will try and will let you know :)
regards
ronan
I will try and will let you know :)
regards
ronan
ASKER
hello cjmos
its working out very well thanks now I need little help
for given three dates i m displaying the result like as shown below
Date Nb de XML Nb de XML(pdf) % reussite Nb de DOC Nb de DOC(pdf) % reussite
Apr 22 2004 159 47 92.5 58 51 87.9
Apr 23 2004 176 173 98.3 36 30 83.3
Apr 24 2004 0 0 0.0 0 0 0.0
-------------------------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ------
I just need to add the total , hence the o/p wud look like below
how do we add all the records to get like one below
Date Nb de XML Nb de XML(pdf) % reussite Nb de DOC Nb de DOC(pdf) % reussite
Apr 22 2004 159 47 92.5 58 51 87.9
Apr 23 2004 176 173 98.3 36 30 83.3
Apr 24 2004 0 0 0.0 0 0 0.0
total 335 220 63.6 94 81 57.06
thanks for the help
waiting for ur reply
its working out very well thanks now I need little help
for given three dates i m displaying the result like as shown below
Date Nb de XML Nb de XML(pdf) % reussite Nb de DOC Nb de DOC(pdf) % reussite
Apr 22 2004 159 47 92.5 58 51 87.9
Apr 23 2004 176 173 98.3 36 30 83.3
Apr 24 2004 0 0 0.0 0 0 0.0
--------------------------
I just need to add the total , hence the o/p wud look like below
how do we add all the records to get like one below
Date Nb de XML Nb de XML(pdf) % reussite Nb de DOC Nb de DOC(pdf) % reussite
Apr 22 2004 159 47 92.5 58 51 87.9
Apr 23 2004 176 173 98.3 36 30 83.3
Apr 24 2004 0 0 0.0 0 0 0.0
total 335 220 63.6 94 81 57.06
thanks for the help
waiting for ur reply
ronan_40060,
I've made a few changes to your original script. See if this works (there are a few ways of doing things like this, i've just chosen a simple one).
########################## #####
my ($xmlTot,$x_pdfTot,$docTot ,$d_pdfTot ,$x_reussi teAv,$d_re ussiteAv,$ cnt) =0;
my $dateStr="";
print "<table align=\"center\" bgcolor=\"#f5deb3\" border=2 bordercolor=\"maroon\"><tr ><td>";
print "Date</td><td>No XML</td><td>Nb XML (pdf)</td><td>% reussite</td><td>Nb Doc</td><td>Nb DOC(pdf)</td><td>% reussite</td></tr>";
while (<FILE>) {
next unless /$date/i;
$dateStr = "<b>Date: $1 $2\n</b>" if /Date:.{4}(.{6}).{10}(.{4} )/;
if ((my ($doc, $d_pdf, $d_reussite) = /DOC:(\d+)[^:]+:(\d+)[^:]+ :\s*([^\n] +)/i) && (my ($xml, $x_pdf, $x_reussite) = /XML:(\d+)[^:]+:(\d+)[^:]+ :\s*([^\n] +)/i))
{
$xmlTot += $xml;
$x_pdfTot += $x_pdf;
$docTot += $doc;
$d_pdfTot += $d_pdf;
$x_reussiteAv = ($x_reussiteAv+$x_reussite )/++$cnt;
$d_reussiteAv = ($d_reussiteAv+$d_reussite )/$cnt;
printf "<tr><td>$dateStr</td><td> $xml</td>< td>$x_pdf< /td><td>%. 1f</td><td >$doc</td> <td>$d_pdf </td><td>% .1f</td></ tr>",$x_re ussite,$d_ reussite;
}
last;
}
printf "<tr><td>total</td><td>$xm lTot</td>< td>$x_pdfT ot</td><td >%.1f</td> <td>$docTo t</td><td> $d_pdfTot< /td><td>%. 1f</td></t r>",$x_reu ssiteAv,$d _reussiteA v;
print "</table>";
close FILE;
########################## ########
I've made a few changes to your original script. See if this works (there are a few ways of doing things like this, i've just chosen a simple one).
##########################
my ($xmlTot,$x_pdfTot,$docTot
my $dateStr="";
print "<table align=\"center\" bgcolor=\"#f5deb3\" border=2 bordercolor=\"maroon\"><tr
print "Date</td><td>No XML</td><td>Nb XML (pdf)</td><td>% reussite</td><td>Nb Doc</td><td>Nb DOC(pdf)</td><td>% reussite</td></tr>";
while (<FILE>) {
next unless /$date/i;
$dateStr = "<b>Date: $1 $2\n</b>" if /Date:.{4}(.{6}).{10}(.{4}
if ((my ($doc, $d_pdf, $d_reussite) = /DOC:(\d+)[^:]+:(\d+)[^:]+
{
$xmlTot += $xml;
$x_pdfTot += $x_pdf;
$docTot += $doc;
$d_pdfTot += $d_pdf;
$x_reussiteAv = ($x_reussiteAv+$x_reussite
$d_reussiteAv = ($d_reussiteAv+$d_reussite
printf "<tr><td>$dateStr</td><td>
}
last;
}
printf "<tr><td>total</td><td>$xm
print "</table>";
close FILE;
##########################
ASKER
hang in there good buddy
I am trying
will put the results soon
thanks
ronan
I am trying
will put the results soon
thanks
ronan
ASKER
I have an HTML form in the front end where in the search criteria a user types in the date in yyyy-mm-dd format and then I am displaying the result of a seach query onto a browser .
All the data i.e records are stored in a log file which is a simple text file
the sample records corresponding to search query 2002-12-12 is
GENERATION DE PDF Date:Thu Dec 12 22:39:50 2002
Nombre XML:224 Nombre de PDF (xml) :204 pourcentage de reussite: 91.0714285714286%
Nombre DOC:27 Nombre de PDF (doc) :27 pourcentage de reussite: 100%
Now for the backend part my entire script is as follows
use warnings;
use strict;
use CGI;
use CGI::Carp qw(fatalsToBrowser);
my $q = new CGI;
my $monthName;
my $longdate=$q->param('START ');
my($year, $month, $day) = split (/-/, $longdate);
my @months = ( ['',0], ['Jan',31], ['Feb',28], ['Mar',31], ['Apr',30], ['May',31],['Jun',30],['Ju l',31],['A ug',31],[' Sep',30],[ 'Oct',31], ['Nov',30] ,['Dec',31 ] );
my $date.= $months[$month][0].' +'.'.*'.$year;
$/ ="GENERATION";
open FILE, "c:/Apache/Apache2/cgi-bin /Upload/ge neration.t xt" or die $!;
print $q->header;
print "<html><body>";
print "<BODY leftmargin=0 topmargin=0>";
print "<table height=\"100%\" width = \"100%\" cellpadding = \"0\" cellspacing = \"0\" border = \"2\" align = \"center\">";
print "<tr height=\"5%\">";
print "<td align = \"center\" colspan =\"1\" bgColor=\"#000080\">";
print "<FONT face=\"Times New Roman\" size=\"5.5\" Color =\"White\"> Result Pour Nb PDF Générés Par + Taux de Réussite </font>";
print "</td>";
print "</tr>";
print "<tr height=\"90%\">";
print "<td width = \"100%\" colspan = \"1\">";
print "<A href=http://localhost/cgi-bin/lastpdf.pl><IMG SRC= FILE:///C:/Apache/Apache2/ cgi-bin/Ac cueil.gif ALIGN=TOP></A>";
print "<br>";
print "<br>";
print "<table align=\"center\" bgcolor=\"aliceblue\" border=2 bordercolor=\"navy\">";
print "<tr>";
print "<td>";
print "<b>Date</b></td><td><b>Nb de XML</b></td><td><b>Nb de XML(pdf)</b></td><td><b>% reussite</b></td><td><b>Nb de DOC</b></td><td><b>Nb de DOC(pdf)</b></td><td><b>% reussite</b></td></tr>";
while (<FILE>) {
next unless /$date/i;
my $dateStr = "$1 $2\n" if /Date:.{4}(.{6}).{10}(.{4} )/;
if ((my ($xml,$x_pdf,$x_reussite) = /XML:(\d+)[^:]+:(\d+)[^:]+ :\s*([^\n] +)/i) && (my ($doc, $d_pdf, $d_reussite) = /DOC:(\d+)[^:]+:(\d+)[^:]+ :\s*([^\n] +)/i))
{
printf "<tr><td>$dateStr</td><td> $xml</td>< td>$x_pdf< /td><td>%. 1f</td><td >$doc</td> <td>$d_pdf </td><td>% .1f",$x_re ussite,$d_ reussite;
}
#last;
}
print "</td>";
print "</tr>";
print "</table>";
close FILE;
print "<br>";
print "<br>";
print "<br>";
print "<tr height=\"5%\">";
print "<td align = \"center\" colspan =\"2\" bgColor=\"#000080\"> </td>";
print "</tr>";
print "</table>";
print "</body></html>";
now I will put your modified script into above and will post the results
:)
thanks for all your help
gonna post the results soon
ronan
All the data i.e records are stored in a log file which is a simple text file
the sample records corresponding to search query 2002-12-12 is
GENERATION DE PDF Date:Thu Dec 12 22:39:50 2002
Nombre XML:224 Nombre de PDF (xml) :204 pourcentage de reussite: 91.0714285714286%
Nombre DOC:27 Nombre de PDF (doc) :27 pourcentage de reussite: 100%
Now for the backend part my entire script is as follows
use warnings;
use strict;
use CGI;
use CGI::Carp qw(fatalsToBrowser);
my $q = new CGI;
my $monthName;
my $longdate=$q->param('START
my($year, $month, $day) = split (/-/, $longdate);
my @months = ( ['',0], ['Jan',31], ['Feb',28], ['Mar',31], ['Apr',30], ['May',31],['Jun',30],['Ju
my $date.= $months[$month][0].' +'.'.*'.$year;
$/ ="GENERATION";
open FILE, "c:/Apache/Apache2/cgi-bin
print $q->header;
print "<html><body>";
print "<BODY leftmargin=0 topmargin=0>";
print "<table height=\"100%\" width = \"100%\" cellpadding = \"0\" cellspacing = \"0\" border = \"2\" align = \"center\">";
print "<tr height=\"5%\">";
print "<td align = \"center\" colspan =\"1\" bgColor=\"#000080\">";
print "<FONT face=\"Times New Roman\" size=\"5.5\" Color =\"White\"> Result Pour Nb PDF Générés Par + Taux de Réussite </font>";
print "</td>";
print "</tr>";
print "<tr height=\"90%\">";
print "<td width = \"100%\" colspan = \"1\">";
print "<A href=http://localhost/cgi-bin/lastpdf.pl><IMG SRC= FILE:///C:/Apache/Apache2/
print "<br>";
print "<br>";
print "<table align=\"center\" bgcolor=\"aliceblue\" border=2 bordercolor=\"navy\">";
print "<tr>";
print "<td>";
print "<b>Date</b></td><td><b>Nb
while (<FILE>) {
next unless /$date/i;
my $dateStr = "$1 $2\n" if /Date:.{4}(.{6}).{10}(.{4}
if ((my ($xml,$x_pdf,$x_reussite) = /XML:(\d+)[^:]+:(\d+)[^:]+
{
printf "<tr><td>$dateStr</td><td>
}
#last;
}
print "</td>";
print "</tr>";
print "</table>";
close FILE;
print "<br>";
print "<br>";
print "<br>";
print "<tr height=\"5%\">";
print "<td align = \"center\" colspan =\"2\" bgColor=\"#000080\">
print "</tr>";
print "</table>";
print "</body></html>";
now I will put your modified script into above and will post the results
:)
thanks for all your help
gonna post the results soon
ronan
ASKER
Holly Molly
Bingo :):):)
its working cjmos
I tested it with a monthly records and the script is giving awesome results
except in the % section where for the entire month i received Total as only 4.2 for both Xml and docs
could u pls check this
thanks a million
your script is working very well
best regards
ronan
Bingo :):):)
its working cjmos
I tested it with a monthly records and the script is giving awesome results
except in the % section where for the entire month i received Total as only 4.2 for both Xml and docs
could u pls check this
thanks a million
your script is working very well
best regards
ronan
Oops, yeh sorry, there is an error in my math...
Change the lines
$x_reussiteAv = ($x_reussiteAv+$x_reussite )/++$cnt;
$d_reussiteAv = ($d_reussiteAv+$d_reussite )/$cnt;
to
$x_reussiteAv = ($x_reussiteTot+=$x_reussi te)/++$cnt ;
$d_reussiteAv = ($d_reussiteTot+=$d_reussi te)/++$cnt ;
And
my ($xmlTot,$x_pdfTot,$docTot ,$d_pdfTot ,$x_reussi teAv,$d_re ussiteAv,$ cnt) =0;
to
my ($xmlTot,$x_pdfTot,$docTot ,$d_pdfTot ,$x_reussi teAv,$d_re ussiteAv,$ cnt,$d_reu ssiteTot,$ x_reussite Tot) =0;
That should fix it.
Change the lines
$x_reussiteAv = ($x_reussiteAv+$x_reussite
$d_reussiteAv = ($d_reussiteAv+$d_reussite
to
$x_reussiteAv = ($x_reussiteTot+=$x_reussi
$d_reussiteAv = ($d_reussiteTot+=$d_reussi
And
my ($xmlTot,$x_pdfTot,$docTot
to
my ($xmlTot,$x_pdfTot,$docTot
That should fix it.
ASKER
thanks cjmos
Im home now
I will do the first work as soon as I go office
thanks for all ur valuable comments
best regards
ronan
Im home now
I will do the first work as soon as I go office
thanks for all ur valuable comments
best regards
ronan
ASKER
hello cjmos
i did the required changes and tested for a monthly records still its giving me result like
for XML its giving me the avg as 40.7 which should have been 90.5
and for DOC its givingme the avg as 36.7 instead of 79.8
what cud be wrong
ronan
i did the required changes and tested for a monthly records still its giving me result like
for XML its giving me the avg as 40.7 which should have been 90.5
and for DOC its givingme the avg as 36.7 instead of 79.8
what cud be wrong
ronan
ASKER
This is now what I did
$x_reussiteAv = (($x_pdfTot)/($xmlTot)*100 );
$d_reussiteAv = (($d_pdfTot)/($docTot)*100 );
and I tested , it works fine for some monthly records but then for some months , it throws an errors that illegal divison by zero at $x_reussiteAv = (($x_pdfTot)/($xmlTot)*100 );
waiting for ur replies cjmos
$x_reussiteAv = (($x_pdfTot)/($xmlTot)*100
$d_reussiteAv = (($d_pdfTot)/($docTot)*100
and I tested , it works fine for some monthly records but then for some months , it throws an errors that illegal divison by zero at $x_reussiteAv = (($x_pdfTot)/($xmlTot)*100
waiting for ur replies cjmos
Can you show me whole code that you've got now?
Also, i've just spotted the reason why the original change didn't work.
$x_reussiteAv = ($x_reussiteTot+=$x_reussi
$d_reussiteAv = ($d_reussiteTot+=$d_reussi
Should have been
$x_reussiteAv = ($x_reussiteTot+=$x_reussi
$d_reussiteAv = ($d_reussiteTot+=$d_reussi
I was incrementing thew counter twice... which was rather silly of me.
ASKER
Ok no worries
here is my whole code
to display all the records for a given month and display their total
use warnings;
use strict;
use CGI;
use CGI::Carp qw(fatalsToBrowser);
my $q = new CGI;
my(%HM) = undef;
my $monthName;
my $longdate=$q->param('START ');
my($year, $month, $day) = split (/-/, $longdate);
my @months = ( ['',0], ['Jan',31], ['Feb',28], ['Mar',31], ['Apr',30], ['May',31],['Jun',30],['Ju l',31],['A ug',31],[' Sep',30],[ 'Oct',31], ['Nov',30] ,['Dec',31 ] );
my $date.= $months[$month][0].' +'.'.*'.$year;
$HM{'Jan'} = "01";$HM{'Feb'} = "02";$HM{'Mar'} = "03";$HM{'Apr'} = "04";$HM{'May'} = "05";$HM{'Jun'} = "06";$HM{'Jul'} = "07";$HM{'Aug'} = "08";$HM{'Sep'} = "09";$HM{'Oct'} = "10";$HM{'Nov'} = "11";$HM{'Dec'} = "12";
my ($xmlTot,$x_pdfTot,$docTot ,$d_pdfTot ,$x_reussi teAv,$d_re ussiteAv,$ cnt,$d_reu ssiteTot,$ x_reussite Tot) =0;
my $dateStr="";
$/ ="GENERATION";
open FILE, "c:/Apache/Apache2/cgi-bin /Upload/ge neration.t xt" or die $!;
print $q->header;
print "<html><body>";
print "<BODY leftmargin=0 topmargin=0>";
print "<table height=\"100%\" width = \"100%\" cellpadding = \"0\" cellspacing = \"0\" border = \"2\" align = \"center\">";
print "<tr height=\"5%\">";
print "<td align = \"center\" colspan =\"1\" bgColor=\"navy\">";
print "<FONT face=\"Times New Roman\" size=\"5.5\" Color = \"White\"> <b>8.Result Pour Nb PDF Générés par Mois </b> </font>";
print "</td>";
print "</tr>";
print "<tr height=\"90%\">";
print "<td width = \"100%\" colspan = \"1\">";
print <<EOF;
<style>
body{font-family:Times New Roman;}
a{color:navy;text-decorati on:none;fo nt:bold}
a:hover{color:#cd853f}
td.menu{background:"white" }
table.menu
{
font-size:100%;
position:absolute;
visibility:hidden;
}
</style>
<script type="text/javascript">
function showmenu(elmnt)
{
document.all(elmnt).style. visibility ="visible"
}
function hidemenu(elmnt)
{
document.all(elmnt).style. visibility ="hidden"
}
</script>
<table width="14%" align= "top" >
<tr bgcolor="navy">
<td onmouseover="showmenu('Acc ueil')" onmouseout="hidemenu('accu eil')">
<font color = white><b>Accueil</b></font ><br />
<table class="menu" id="accueil" width="100%">
<tr><td class="menu"><a href="http://localhost/cgi-bin/functionality.pl">Statistics GEDI</a></td></tr>
<tr><td class="menu"><a href="http://localhost/cgi-bin/lastpdf.pl">Recherche Encore</a></td></tr>
</table>
</td>
</tr>
</table>
EOF
#print "<A href=http://localhost/cgi-bin/lastpdf.pl><IMG SRC= FILE:///C:/Apache/Apache2/ cgi-bin/Ac cueil.gif ALIGN=TOP></A>";
#print "<br>";
#print "<br>";
print "<table align=\"center\" bgcolor=\"aliceblue\" border=2 bordercolor=\"navy\">";
print "<tr>";
print "<td>";
print "<b>Date</b></td><td><b>Nb de XML</b></td><td><b>Nb de XML(pdf)</b></td><td><b>% reussite</b></td><td><b>Nb de DOC</b></td><td><b>Nb de DOC(pdf)</b></td><td><b>% reussite</b></td></tr>";
while (<FILE>) {
next unless /$date/i;
my $dateStr = "$2/$HM{$1}/$3\n" if /Date:.{4}(.{3})\s(.{2}).{ 10}(.{4})/ ;
if ((my ($xml,$x_pdf,$x_reussite) = /XML:(\d+)[^:]+:(\d+)[^:]+ :\s*([^\n] +)/i) && (my ($doc, $d_pdf, $d_reussite) = /DOC:(\d+)[^:]+:(\d+)[^:]+ :\s*([^\n] +)/i))
{
$xmlTot += $xml;
$x_pdfTot += $x_pdf;
$docTot += $doc;
$d_pdfTot += $d_pdf;
#$x_reussiteAv = ($x_reussiteAv+$x_reussite )/++$cnt;
#$d_reussiteAv = ($d_reussiteAv+$d_reussite )/$cnt;
#$x_reussiteAv = ($x_reussiteTot+=$x_reussi te)/++$cnt ;
#$d_reussiteAv = ($d_reussiteTot+=$d_reussi te)/++$cnt ;
#$x_reussiteAv = (($x_pdfTot)/($xmlTot)*100 );
#$d_reussiteAv = (($d_pdfTot)/($docTot)*100 );
$x_reussiteAv = ($x_reussiteTot+=$x_reussi te)/++$cnt ;
$d_reussiteAv = ($d_reussiteTot+=$d_reussi te)/$cnt;
printf "<tr><td>$dateStr</td><td> $xml</td>< td>$x_pdf< /td><td>%. 1f</td><td >$doc</td> <td>$d_pdf </td><td>% .1f</td></ tr>",$x_re ussite,$d_ reussite;
}
#last;
}
printf "<tr><td><b>Total</b></td> <td><b>$xm lTot</b></ td><td><b> $x_pdfTot< /b></td><t d><b>%.1f< /b></td><t d><b>$docT ot</b></td ><td><b>$d _pdfTot</b ></td><td> <b>%.1f</b ></td></tr >",$x_reus siteAv,$d_ reussiteAv ;
print "</table>";
close FILE;
print "<br>";
print "<tr height=\"6%\">";
print "<td align = \"center\" colspan =\"2\" bgColor=\"#000080\"> </td>";
print "</tr>";
print "</table>";
print "</body></html>";
here is my whole code
to display all the records for a given month and display their total
use warnings;
use strict;
use CGI;
use CGI::Carp qw(fatalsToBrowser);
my $q = new CGI;
my(%HM) = undef;
my $monthName;
my $longdate=$q->param('START
my($year, $month, $day) = split (/-/, $longdate);
my @months = ( ['',0], ['Jan',31], ['Feb',28], ['Mar',31], ['Apr',30], ['May',31],['Jun',30],['Ju
my $date.= $months[$month][0].' +'.'.*'.$year;
$HM{'Jan'} = "01";$HM{'Feb'} = "02";$HM{'Mar'} = "03";$HM{'Apr'} = "04";$HM{'May'} = "05";$HM{'Jun'} = "06";$HM{'Jul'} = "07";$HM{'Aug'} = "08";$HM{'Sep'} = "09";$HM{'Oct'} = "10";$HM{'Nov'} = "11";$HM{'Dec'} = "12";
my ($xmlTot,$x_pdfTot,$docTot
my $dateStr="";
$/ ="GENERATION";
open FILE, "c:/Apache/Apache2/cgi-bin
print $q->header;
print "<html><body>";
print "<BODY leftmargin=0 topmargin=0>";
print "<table height=\"100%\" width = \"100%\" cellpadding = \"0\" cellspacing = \"0\" border = \"2\" align = \"center\">";
print "<tr height=\"5%\">";
print "<td align = \"center\" colspan =\"1\" bgColor=\"navy\">";
print "<FONT face=\"Times New Roman\" size=\"5.5\" Color = \"White\"> <b>8.Result Pour Nb PDF Générés par Mois </b> </font>";
print "</td>";
print "</tr>";
print "<tr height=\"90%\">";
print "<td width = \"100%\" colspan = \"1\">";
print <<EOF;
<style>
body{font-family:Times New Roman;}
a{color:navy;text-decorati
a:hover{color:#cd853f}
td.menu{background:"white"
table.menu
{
font-size:100%;
position:absolute;
visibility:hidden;
}
</style>
<script type="text/javascript">
function showmenu(elmnt)
{
document.all(elmnt).style.
}
function hidemenu(elmnt)
{
document.all(elmnt).style.
}
</script>
<table width="14%" align= "top" >
<tr bgcolor="navy">
<td onmouseover="showmenu('Acc
<font color = white><b>Accueil</b></font
<table class="menu" id="accueil" width="100%">
<tr><td class="menu"><a href="http://localhost/cgi-bin/functionality.pl">Statistics GEDI</a></td></tr>
<tr><td class="menu"><a href="http://localhost/cgi-bin/lastpdf.pl">Recherche Encore</a></td></tr>
</table>
</td>
</tr>
</table>
EOF
#print "<A href=http://localhost/cgi-bin/lastpdf.pl><IMG SRC= FILE:///C:/Apache/Apache2/
#print "<br>";
#print "<br>";
print "<table align=\"center\" bgcolor=\"aliceblue\" border=2 bordercolor=\"navy\">";
print "<tr>";
print "<td>";
print "<b>Date</b></td><td><b>Nb
while (<FILE>) {
next unless /$date/i;
my $dateStr = "$2/$HM{$1}/$3\n" if /Date:.{4}(.{3})\s(.{2}).{
if ((my ($xml,$x_pdf,$x_reussite) = /XML:(\d+)[^:]+:(\d+)[^:]+
{
$xmlTot += $xml;
$x_pdfTot += $x_pdf;
$docTot += $doc;
$d_pdfTot += $d_pdf;
#$x_reussiteAv = ($x_reussiteAv+$x_reussite
#$d_reussiteAv = ($d_reussiteAv+$d_reussite
#$x_reussiteAv = ($x_reussiteTot+=$x_reussi
#$d_reussiteAv = ($d_reussiteTot+=$d_reussi
#$x_reussiteAv = (($x_pdfTot)/($xmlTot)*100
#$d_reussiteAv = (($d_pdfTot)/($docTot)*100
$x_reussiteAv = ($x_reussiteTot+=$x_reussi
$d_reussiteAv = ($d_reussiteTot+=$d_reussi
printf "<tr><td>$dateStr</td><td>
}
#last;
}
printf "<tr><td><b>Total</b></td>
print "</table>";
close FILE;
print "<br>";
print "<tr height=\"6%\">";
print "<td align = \"center\" colspan =\"2\" bgColor=\"#000080\">
print "</tr>";
print "</table>";
print "</body></html>";
ASKER
Now the basic idea is like this
for a given month
there are dates where no pdf documents were created from xml and doc files
so when we calculate the total of al XML for a a given month suppose for april it comes to be 1520
and total of no of pdf files created from xml are 1320 for that month
so the overall the rate wud be (1320/1520)*100 = 86.6
and ourcode calculates the average of all the % (total of all %)/no of days so the result of this is different than the result that we got from (1320/1520)*100 = 86.6
what we need is (1320/1520)*100 = 86.6
I am also working , If find something I will let u know
thanks cjmos for all your help
do let me know what u think and how can we manage to get the required result
best wishes
ronan
for a given month
there are dates where no pdf documents were created from xml and doc files
so when we calculate the total of al XML for a a given month suppose for april it comes to be 1520
and total of no of pdf files created from xml are 1320 for that month
so the overall the rate wud be (1320/1520)*100 = 86.6
and ourcode calculates the average of all the % (total of all %)/no of days so the result of this is different than the result that we got from (1320/1520)*100 = 86.6
what we need is (1320/1520)*100 = 86.6
I am also working , If find something I will let u know
thanks cjmos for all your help
do let me know what u think and how can we manage to get the required result
best wishes
ronan
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
thanks cjmos
you solved the big problem
I am home now but I am downloading Activeperl and Apache sever and I will test the whole code at home
thanks
I will keep you posted
Thanks a million for all
I am gonna download Komodo ide for perl (trial version :(:( from activestate
best regards
ronan
you solved the big problem
I am home now but I am downloading Activeperl and Apache sever and I will test the whole code at home
thanks
I will keep you posted
Thanks a million for all
I am gonna download Komodo ide for perl (trial version :(:( from activestate
best regards
ronan
ASKER
I tested it at home and its working excellent
Great man , you solved it :):):):)
thanks a lot
I wish to come up woth another question again ;)
best wishes
ronan
Great man , you solved it :):):):)
thanks a lot
I wish to come up woth another question again ;)
best wishes
ronan
No probs. Glad to help :)
I havn't had time to test this but try altering the above to:
######################
print "<table align=\"center\" bgcolor=\"#f5deb3\" border=2 bordercolor=\"maroon\">";
print "<tr>";
print "<td>";
print "Date</td><td>No XML</td><td>Nb XML (pdf)</td><td>% reussite</td><td>Nb Doc</td><td>Nb DOC(pdf)</td><td>% reussite</td></tr>";
while (<FILE>) {
next unless /$date/i;
$dateStr = "<b>Date: $1 $2\n</b>" if /Date:.{4}(.{6}).{10}(.{4}
if ((my ($doc, $d_pdf, $d_reussite) = /DOC:(\d+)[^:]+:(\d+)[^:]+
{
printf "<tr><td>$dateStr</td><td>
}
last;
}
print "</td>";
print "</tr>";
print "</table>";
close FILE;
##########################