Ask a Question related to PERL Miscellaneous, Design and Development.
-
raven #1
Parsing A Report
I have a system report that some of you may be familiar with. It is
the output from the print_manifest command on an HP-UX system with
ignite installed. There are divisions in the text file that I am
trying to break up, but feel like I am going about wrong. I am trying
to extract the block of text within 'Installed Software' up to the
next major heading. Can someone check my work and comment? Thanks. See
below:
Report:
Installed Software
Your system was installed with HP-UX version B.11.11.
Your system has the following software products installed and
configured on the system disk drive(s).
Product Revision Description
B2491BA B.11.11 MirrorDisk/UX
B3701AA C.03.25.00 HP GlancePlus/UX Pak for s800
11i
B3913DB C.03.30.01 HP aC++ Compiler (S800)
B5725AA B.3.3.116 HP-UX Installation Utilities
(Ignite-UX)
B6834AA B.01.00 HP-UX Security Patch Check Tool
B9901AA A.03.05 HP IPFilter 3.5alpha5
BUNDLE11i B.11.11.0102.2 Required Patch Bundle for HP-UX
11i, February 2001
CDE-English B.11.11 English CDE Environment
FDDI-00 B.11.11.01 PCI FDDI;Supptd
HW=A3739A/A3739B;SW=J3626AA
FibrChanl-00 B.11.11.06 PCI/HSC FibreChannel;Supptd
HW=A6684A,A6685A,A5158A
GigEther-00 B.11.11.14 PCI/HSC GigEther;Supptd
HW=A4926A/A4929A/A4924A/A4925A;SW=J1642AA
HPUX11i-OE B.11.11.0106 HP-UX 11i Operating Environment
Component
HPUXBase64 B.11.11 HP-UX 64-bit Base OS
HPUXBaseAux B.11.11.0106 HP-UX Base OS Auxiliary
HWEnable11i B.11.11.0106.8 Hardware Enablement Patches for
HP-UX 11i, June 2001
Ignite-UX-11-11 B.3.3.116 HP-UX Installation Utilities
for Installing 11.11 Systems
J4189-11001B E.10.18 Hewlett-Packard JetDirect
Printer Installer for Unix
OnlineDiag B.11.11.03.08 HPUX 11.11 Support Tools
Bundle, Jun 2001
RAID-00 B.11.11.01 PCI RAID; Supptd HW=A5856A
LVM File System Configuration
This system is configured with Logical Volume Manager (LVM) file
systems.
Refer to the File System layout section for information on the LVM
layout.
JFS File System Configuration
This system is configured with a Journaled File System (referred
to
as either JFS or VXFS). Refer to the File System layout section
for
information on JFS/VXFS file systems.
Code:
#!/usr/contrib/bin/perl -w
open SOFTWARE, "system.txt" or die "Cannot open file!";
$flag = 0;
while (<SOFTWARE>) {
if (/^Installed Software/) {
$flag = 1;
next;
}
if ($flag) {
last if (/^\w+/);
# Where we do the work.
}
}
raven Guest
-
preflight XML report differs from droplet report
Hi all, When i create a xml-report 'by hand' with the preflight tool, it generates much more info then when i use the same preflight profile as a... -
Bug report in 7.4
Is this known? If you create a table with a SERIAL and then rename the table you can't dump/restore the database. The create table creates a... -
PDF::Report
Hi I've been using PDF::Report, which is a nice wrapper around PDF::API2. My problem is that it doesn't handle the special Danish characters æøå... -
How to link 3 different combo boxex in a form (as report criteria) to the report
I would like to use 3 combo boxes in a form as parameter criteria for a report. When I open a report, there will be a pop up form with 3 combo... -
Report
I have a form with a subform set up on a tab format. My main form is linked to a table with customer info (Name, address etc) The sub form is a... -
Tore Aursand #2
Re: Parsing A Report
On Thu, 18 Sep 2003 09:43:02 -0700, raven wrote:
Actually, it's very easy. I won't provide you with any code for now, only> I have a system report that some of you may be familiar with. It is
> the output from the print_manifest command on an HP-UX system with
> ignite installed. There are divisions in the text file that I am
> trying to break up, but feel like I am going about wrong. I am trying
> to extract the block of text within 'Installed Software' up to the
> next major heading. Can someone check my work and comment? Thanks. See
> below:
> [...]
the "way of thinking" (although I might be wrong).
Start collecting data after you've recognized that 'Installed Software' is
the beginning string on the line.
Stop collecting data when you reach the next string that begins at the
beginning of the line (hope you'll understand what I mean with that), as
all the lines you want seem to be indented.
However, I wouldn't have done it this way. :-) I would have looped
through the lines and started collection data as soon as I reach something
I can count as 3 columns (eventually, and in addition, after having met
that 'Product', 'Revision', 'Description' line).
Something like that (although I have no idea if it works);
while ( <DATA> ) {
chomp;
my @cols = split( /\s+/ );
if ( $cols[0] =~ m,\d+, ) {
## Yeah, I want those lines with numbers in the first column!
print join( "\t", @cols );
}
}
I don't know if this works; I'm watching soccer and have had a few beer,
so... :-)
One thing I've learnt during my "Perl period" is that you never should use> $flag = 0;
any "flags" in your code. If you have to, you most probably do something
wrong. Can't really explain it, though...
--
Tore Aursand <tore@aursand.no>
"You know the world is going crazy when the best rapper is white, the best
golfer is black, France is accusing US of arrogance and Germany doesn't
want to go to war."
Tore Aursand Guest



Reply With Quote

