Aali Naser wrote:
Hello All,

Hello,

I have a file with the info in the following format;

================Start of File=====================
Server Name: ABCDEF
Manufacturer: Dell
Model: Some Model
Number Of Processors (Includes MultiThread): 2
Maximum Clock Speed: 3 - GHZ
Serial Number: 123456
Proc Usage: (1 Proc Sample Only) 1%
Mem Total: 2 - GB
DeviceID:  C:  Space: 20GB  Used Space: 2GB  UTIL: 61.4991581037678%
DeviceID:  E:  Space: 567.90882304GB  Used Space: 32GB  UTIL:
5.66111272649405%
DeviceID:  F:  Space: 5GB  Used Space: 3GB  UTIL: 7.68405957709316%
Log File Directory: C:\WINDOWS\system32\LogFiles
196.136
Service Pack: 2.0
Connections: 53
HTTPERR Folder:
OS Directory: C:\WINDOWS
System Directory: C:\WINDOWS\system32
----------------------------
Server Name: GHIJKL
Manufacturer: Dell
Model: Some Model
Number Of Processors (Includes MultiThread): 4
Maximum Clock Speed: 3 - GHZ
Serial Number: 123456
Proc Usage: (1 Proc Sample Only) 0%
Mem Total: 2 - GB
DeviceID:  C:  Space: 2GB  Used Space: 9GB  UTIL: 46.0333821902412%
DeviceID:  E:  Space: 5GB  Used Space: 3GB  UTIL: 7.68405957709316%
69.136
Service Pack: 2.0
Connections: 206
HTTPERR Folder:
OS Directory: C:\WINDOWS
System Directory: C:\WINDOWS\system32
----------------------------
================End of File=====================

Each machine entry is seperated by a "----------------------------" in the
file. I need to put together each machine entry in the following way;

*Server_Name  Manufacture   Model   # of Procs   Serial#  Total_Mem  Disk1
Disk2  Disk3  Service_Pack*

The number of disks could be two or more for each machine and I want to be
able to capture all of them.

Can any one help me with the logic for this type data processing?

#!/usr/bin/perl
use warnings;
use strict;

open SERVERS, '<', 'sample.txt' or die "Cannot open 'sample.txt' $!";

# set the Input Record Separator
$/ = "--------------------------\n";

while ( <SERVERS> ) {
    my $server_name = /^Server Name:\s+(.+)/m;
    my $manufac     = /^Manufacturer:\s+(.+)/m;
    my $model       = /^Model:\s+(.+)/m;
my $num_procs = /^Number Of Processors (Includes MultiThread):\s+(\d+)/m;
    my $serial_num  = /^Serial Number:\s+(.+)/m;
    my $mem         = /^Mem Total:\s+(.+)/m;
    my @disks       = /^DeviceID:\s+([A-Z]:)/mg;
    my $spack       = /^Service Pack:\s+(.+)/m;

print join( ':', $server_name, $manufac, $model, $num_procs, $serial_num, $mem, @disks, $spack ), "\n";
    }

__END__



John
--
Perl isn't a toolbox, but a small machine shop where you
can special-order certain sorts of tools at low cost and
in short order.                            -- Larry Wall

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/


Reply via email to