This is ugly, works, but ugly. I'm sure there has got to be a better way.
I'm tracking all my client boxes for MS patches. This script builds an HTML table of all the MS patches and compares to number of installed clients to not installed.
The patches are labeled like so: MS03-001, MS03-039, MS00-005, MS01-008, etc etc.
The 3rd and 4th characters represent the years.
I'm sorting the data by year from 03 - 98 for display and here's how i'm doing it. I'm also padding the installed/not installed numbers with zeros in an ugly way.
Please slap me around a bit and correct my ways.
.
.
.
%pad = ('1', '000', '2', '00', '3', '0', '4', '');
@years = qw[05 04 03 02 01 00 99 98];
@keys = sort keys %AllPatches;
foreach $year (@years) {
foreach $BulletinID (@keys) {
next if (substr($BulletinID,2,2) ne $year);
next if ($MissingPatchList{$BulletinID}+$FoundPatchList{$Bulle
+tinID}==0);
if ($counter == 7) {
print HTML "</tr><tr>\n";
$counter = 0;
}
$MissingPatchList{$BulletinID} = "0" if (!$MissingPatchList{$B
+ulletinID});
$FoundPatchList{$BulletinID} = "0" if (!$FoundPatchList{$Bulle
+tinID});
$MissingPatchList{$BulletinID} = "$pad{(length($MissingPatchLi
+st{$BulletinID}))}$MissingPatchList{$BulletinID}";
$FoundPatchList{$BulletinID} = "$pad{(length($FoundPatchList{$
+BulletinID}))}$FoundPatchList{$BulletinID}";
.
.
.
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.