freelanceprogrammers.org Forum Index » Perl

Report Formatting


View user's profile Post To page top
bmvh01 Posted: Thu May 05, 2005 12:45 am


Joined: 05 May 2005

Posts: 1
Report Formatting
I have a text file that I would like to display as a web page with
some additional html functions.
At each "System Configuration" statement I would like to insert and
html anchor tag "<a spec#> where # is a number from 1 to 9.

Now the hard part - this file is created daily and placed in a
directory overwriting the existing file, so I would like to create
a "template" that reads the file and creates the appropriate anchor
tags dynamically. Is this possible, and how would I go about
starting this?

Thanks in advance.
The file is a sar report and looks like this:

#################################################
AIX beips88 2 5 000C79AF4C00 05/04/05

System Configuration: lcpu=6

07:59:01 %usr %sys %wio %idle
08:19:01 0 0 0 100
08:39:01 0 0 0 100
08:59:00 0 0 0 100
09:19:00 0 0 0 100
09:39:00 0 0 0 100
09:59:00 0 0 0 100
10:19:00 0 0 0 100
10:39:00 0 0 0 100
10:59:00 0 0 0 100
11:19:00 0 0 0 100
11:39:00 0 0 0 100
11:59:00 0 0 0 100
12:19:00 0 0 0 100
12:39:00 0 0 0 100
12:59:00 0 0 0 100
13:19:00 0 0 0 100
13:39:00 0 0 0 100
13:59:00 0 0 0 100

Average 0 0 0 100

System Configuration: lcpu=6

07:59:01 bread/s lread/s %rcache bwrit/s lwrit/s %wcache pread/s
pwrit/s
08:19:01 0 0 0 0 0 0
0 0
08:39:01 0 0 0 0 0 0
0 0
08:59:00 0 0 0 0 0 0
0 0
09:19:00 0 0 0 0 0 0
0 0
09:39:00 0 0 0 0 0 0
0 0
09:59:00 0 0 0 0 0 0
0 0
10:19:00 0 0 0 0 0 0
0 0
10:39:00 0 0 0 0 0 0
0 0
10:59:00 0 0 0 0 0 0
0 0
11:19:00 0 0 0 0 0 0
0 0
11:39:00 0 0 0 0 0 0
0 0
11:59:00 0 0 0 0 0 0
0 0
12:19:00 0 0 0 0 0 0
0 0
12:39:00 0 0 0 0 0 0
0 0
12:59:00 0 0 0 0 0 0
0 0
13:19:00 0 0 0 0 0 0
0 0
13:39:00 0 0 0 0 0 0
0 0
13:59:00 0 0 0 0 0 0
0 0

Average 0 0 0 0 0 0
0 0

System Configuration: lcpu=6

07:59:01 scall/s sread/s swrit/s fork/s exec/s rchar/s wchar/s
08:19:01 24 4 2 0.03 0.03 2152 134
08:39:01 11 2 0 0.00 0.00 1146 3
08:59:00 11 2 0 0.00 0.00 1125 3
09:19:00 13 2 0 0.01 0.01 1513 5
09:39:00 11 2 0 0.00 0.00 1146 3
09:59:00 11 2 0 0.00 0.00 1125 3
10:19:00 13 3 0 0.01 0.01 1584 6
10:39:00 38 5 2 0.04 0.03 3157 423
10:59:00 52 6 2 0.04 0.03 4997 398
11:19:00 21 4 0 0.01 0.01 2395 42
11:39:00 35 3 1 0.02 0.02 3244 181
11:59:00 20 3 1 0.01 0.01 1886 56
12:19:00 15 4 0 0.01 0.01 2015 14
12:39:00 16 3 1 0.01 0.01 1272 84
12:59:00 52 4 1 0.03 0.03 5535 328
13:19:00 37 5 1 0.02 0.02 4061 235
13:39:00 11 2 0 0.00 0.00 1146 3
13:59:00 15 3 1 0.00 0.00 1222 111

Average 23 3 1 0.01 0.01 2262 113

System Configuration: lcpu=6

07:59:01 cswch/s
08:19:01 58
08:39:01 54
08:59:00 54
09:19:00 54
09:39:00 54
09:59:00 54
10:19:00 54
10:39:00 59
10:59:00 59
11:19:00 55
11:39:00 57
11:59:00 56
12:19:00 55
12:39:00 57
12:59:00 57
13:19:00 56
13:39:00 54
13:59:00 56

Average 56

System Configuration: lcpu=6

07:59:01 rawch/s canch/s outch/s rcvin/s xmtin/s mdmin/s
08:19:01 0 0 22 0 0 0
08:39:01 0 0 0 0 0 0
08:59:00 0 0 0 0 0 0
09:19:00 0 0 0 0 0 0
09:39:00 0 0 0 0 0 0
09:59:00 0 0 0 0 0 0
10:19:00 0 0 0 0 0 0
10:39:00 1 0 9 0 0 0
10:59:00 1 0 7 0 0 0
11:19:00 0 0 1 0 0 0
11:39:00 0 0 4 0 0 0
11:59:00 0 0 2 0 0 0
12:19:00 0 0 0 0 0 0
12:39:00 0 0 18 0 0 0
12:59:00 0 0 8 0 0 0
13:19:00 0 0 6 0 0 0
13:39:00 0 0 0 0 0 0
13:59:00 0 0 39 0 0 0

Average 0 0 7 0 0 0

System Configuration: lcpu=6

07:59:01 iget/s lookuppn/s dirblk/s
08:19:01 0 1 0
08:39:01 0 1 0
08:59:00 0 0 0
09:19:00 0 1 0
09:39:00 0 1 0
09:59:00 0 0 0
10:19:00 0 1 0
10:39:00 0 2 0
10:59:00 0 2 0
11:19:00 0 1 0
11:39:00 0 1 0
11:59:00 0 1 0
12:19:00 0 1 0
12:39:00 0 1 1
12:59:00 0 2 0
13:19:00 0 1 0
13:39:00 0 1 0
13:59:00 0 1 0

Average 0 1 0

System Configuration: lcpu=6

07:59:01 runq-sz %runocc swpq-sz %swpocc
08:19:01 1.0 0 1.0 0
08:39:01 1.0 0 1.0 0
08:59:00 1.0 0 1.0 0
09:19:00 1.0 0 1.0 0
09:39:00 1.0 0 1.0 0
09:59:00 1.0 0 1.0 0
10:19:00 1.0 0
10:39:00 1.0 0 1.0 0
10:59:00 1.0 0
11:19:00 1.0 0 1.0 0
11:39:00 1.0 13 1.0 0
11:59:00 1.0 0 1.0 0
12:19:00 1.0 0 1.0 0
12:39:00 1.0 0 1.0 0
12:59:00 1.0 0 1.0 0
13:19:00 1.0 0 1.0 0
13:39:00 1.0 0 1.0 0
13:59:00 1.0 0

Average 1.0 1 1.0 0

System Configuration:

07:59:01 proc-sz inod-sz file-sz thrd-sz
08:19:01 71/262144 364/66098 442/511 216/524288
08:39:01 71/262144 364/66099 442/511 216/524288
08:59:00 71/262144 364/66100 442/511 216/524288
09:19:00 71/262144 364/66102 442/511 216/524288
09:39:00 71/262144 364/66103 442/511 216/524288
09:59:00 71/262144 364/66104 442/511 216/524288
10:19:00 71/262144 364/66106 442/511 216/524288
10:39:00 71/262144 364/66129 442/511 216/524288
10:59:00 71/262144 364/66156 442/511 216/524288
11:19:00 71/262144 364/66163 442/511 216/524288
11:39:00 72/262144 367/66178 445/511 217/524288
11:59:00 71/262144 364/66181 442/511 216/524288
12:19:00 71/262144 364/66184 442/511 216/524288
12:39:00 73/262144 368/66189 446/511 218/524288
12:59:00 71/262144 364/66209 442/511 216/524288
13:19:00 71/262144 364/66224 442/511 216/524288
13:39:00 71/262144 364/66225 442/511 216/524288
13:59:00 71/262144 364/66226 442/511 216/524288


System Configuration: lcpu=6

07:59:01 msg/s sema/s
08:19:01 0.01 0.00
08:39:01 0.01 0.00
08:59:00 0.01 0.00
09:19:00 0.01 0.00
09:39:00 0.01 0.00
09:59:00 0.01 0.00
10:19:00 0.01 0.00
10:39:00 0.01 0.00
10:59:00 0.01 0.00
11:19:00 0.01 0.00
11:39:00 0.01 0.00
11:59:00 0.01 0.00
12:19:00 0.01 0.00
12:39:00 0.01 0.00
12:59:00 0.01 0.00
13:19:00 0.01 0.00
13:39:00 0.01 0.00
13:59:00 0.01 0.00

Average 0.01 0.00
####################################################
Reply with quote
Send private message
View user's profile Post To page top
paulalapatt Posted: Thu May 05, 2005 3:38 pm


Joined: 06 Apr 2005

Posts: 12
Report Formatting
Dear Mike,

This is very much possible.

The code to achieve this should approximately look like this, this is just
an impromptu created code, so please correct it to meet your requirements:





#!/usr/bin/perl

print "Content-type:text/html

";

open(FH, `log.1`);
@AAnchors = ();
$HTMLString = "";
while(<FH>) {
if(/System Configuration/) {
#print $. . "$_" . "<br>";
push(@AAnchors, $.);
$HTMLString .= qq{<a name="$.">$_</a><br>};
} else {
$HTMLString .= qq{$_<br>};
}
}

print qq{The Links are: <br>};
foreach (@AAnchors) {
print qq{<a href="#}.$_.qq{">$_</a><br>};
}
print $HTMLString;
Reply with quote
Send private message
Post new topic Reply to topic
Display posts from previous:   
 

All times are GMT
Page 1 of 1
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
Freelace Website Designer - Customer web design and software building.
China Wholesale - Electronics Products
Character Studio - Tutorials and Help