Perhaps:
use strict;
use warnings;
use Data::Dumper;
my %records;
local $/ = "\n\n";
while (<DATA>) {
next if !/^(\d+):(.*)/s;
$records{$1} = $2;
}
print Dumper(\%records);
__DATA__
Storage system address: 192.168.1.2
Storage system port: 443
HTTPS connection
1: ID = disk_dpe_0_0
Enclosure = DPE_0
Slot = 0
Name = DPE Disk 0
Health state = OK (5)
Health details = "The component is operating normally. No ac
+tion is require
+d."
Type = SAS
Capacity = 288196762624 (268.4G)
Rotational speed = 15000 rpm
User capacity = 236420176896 (220.2G)
Pool = performance
Current speed = 6 Gbps
Maximum speed = 6 Gbps
Manufacturer = SEAGATE
Model = STE30065 CLAR300
Vendor capacity = 322122547200 (300.0G)
Part number = 005049273
Serial number = 6SJ2C6MV
Firmware revision = ES0E
WWN = 06:00:00:00:05:00:00:00:00:00:00:00:00:00:00
+:03
2: ID = disk_dpe_0_1
Enclosure = DPE_0
Slot = 1
Name = DPE Disk 1
Health state = OK (5)
Health details = "The component is operating normally. No ac
+tion is require
+d."
Type = SAS
Capacity = 288196762624 (268.4G)
Rotational speed = 15000 rpm
User capacity = 236420176896 (220.2G)
Pool = performance
Current speed = 6 Gbps
Maximum speed = 6 Gbps
Manufacturer = SEAGATE
Model = STE30065 CLAR300
Vendor capacity = 322122547200 (300.0G)
Part number = 005049273
Serial number = 6SJ28QF3
Firmware revision = ES0E
WWN = 06:00:00:00:05:00:00:00:01:00:00:00:01:00:00
+:03
Prints:
$VAR1 = {
'1' => ' ID = disk_dpe_0_0
Enclosure = DPE_0
Slot = 0
Name = DPE Disk 0
Health state = OK (5)
Health details = "The component is operating normally. No ac
+tion is required."
Type = SAS
Capacity = 288196762624 (268.4G)
Rotational speed = 15000 rpm
User capacity = 236420176896 (220.2G)
Pool = performance
Current speed = 6 Gbps
Maximum speed = 6 Gbps
Manufacturer = SEAGATE
Model = STE30065 CLAR300
Vendor capacity = 322122547200 (300.0G)
Part number = 005049273
Serial number = 6SJ2C6MV
Firmware revision = ES0E
WWN = 06:00:00:00:05:00:00:00:00:00:00:00:00:00:00
+:03
',
'2' => ' ID = disk_dpe_0_1
Enclosure = DPE_0
Slot = 1
Name = DPE Disk 1
Health state = OK (5)
Health details = "The component is operating normally. No ac
+tion is required."
Type = SAS
Capacity = 288196762624 (268.4G)
Rotational speed = 15000 rpm
User capacity = 236420176896 (220.2G)
Pool = performance
Current speed = 6 Gbps
Maximum speed = 6 Gbps
Manufacturer = SEAGATE
Model = STE30065 CLAR300
Vendor capacity = 322122547200 (300.0G)
Part number = 005049273
Serial number = 6SJ28QF3
Firmware revision = ES0E
WWN = 06:00:00:00:05:00:00:00:01:00:00:00:01:00:00
+:03
'
};
Note the use of local $/ = "\n\n"; to turn the line break "character" (record separator) into two line breaks as an easy way of reading the input as a stream of records.
Optimising for fewest key strokes only makes sense transmitting to Pluto or beyond
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.
|