jet speed wrote:
Hi All,
Hello,
I put togather a piece of code with some help, to capture the output as
below from a file "cxout1" as below. I am sure this can be written in few
lines or even differnt way of getting the same out put with use of hash etc.
Kindly help me to optimize the code. Any help would be much appericated.
output from the script
---------------------------------
The Clarion Array Serial Number is CK200061101100
LUN INFO POLICY-TYPE OWNER PSEUDO DEVICE
LUN 415 policy=CLAROpt current=SP A emcpower3a
LUN 815 policy=CLAROpt current=SP B emcpower4a
file contents cxout1
-----------------------------
Pseudo name=emcpower3a
CLARiiON ID=CK200061101100 [JAZZ]
Logical device ID=600601601496160012288D48703EDB11 [LUN 415]
state=alive; policy=CLAROpt; priority=0; queued-IOs=0
Owner: default=SP A, current=SP A
==============================================================================
---------------- Host --------------- - Stor - -- I/O Path - -- Stats
---
### HW Path I/O Paths Interf. Mode State Q-IOs
Errors
==============================================================================
2310 [EMAIL PROTECTED]/[EMAIL PROTECTED]/[EMAIL PROTECTED] c3t20d0s0 SP
A0 active alive 0
1
2310 [EMAIL PROTECTED]/[EMAIL PROTECTED]/[EMAIL PROTECTED] c3t21d0s0 SP
A1 active alive 0
1
Pseudo name=emcpower4a
CLARiiON ID=CK200061101100 [JAZZ]
Logical device ID=6006016014961600625987643E38DB11 [LUN 815]
state=alive; policy=CLAROpt; priority=0; queued-IOs=0
Owner: default=SP B, current=SP B
==============================================================================
---------------- Host --------------- - Stor - -- I/O Path - -- Stats
---
### HW Path I/O Paths Interf. Mode State Q-IOs
Errors
==============================================================================
2310 [EMAIL PROTECTED]/[EMAIL PROTECTED]/[EMAIL PROTECTED] c3t20d1s0 SP
A0 active alive 0
1
2310 [EMAIL PROTECTED]/[EMAIL PROTECTED]/[EMAIL PROTECTED] c3t21d1s0 SP
A1 active alive 0
1
my code
[ snip code ]
This appears to work:
#!/usr/bin/perl
use warnings;
use strict;
$/ = ''; # set paragraph mode
my $filename = 'cxout1';
open FILE, '<', $filename or die "Could not open $filename: $!";
my ( @IDS, @data, %seen );
while ( <FILE> ) {
my ( $ID ) = /ID=(CK\d+)/;
push @IDS, $ID unless $seen{ $ID }++;
push @data, [ /\[(LUN\s+\d+)]/, /(policy=[^;]+);/,
/\b(current=.*\S)/, /Pseudo name=(.*\S)/ ];
}
print "\nThe Clariion Array Serial Number is @IDS\n\n";
print "LUN INFO\t POLICY-TYPE\t\t OWNER\t\t PSEUDO DEVICE\n";
for ( @data ) {
print join( "\t\t ", @$_ ), "\n";
}
__END__
So you are still running Data General hardware?
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/