note
moritz
<p>How about just parsing the whole thing, and afterward using those fields you're interested in, and simply ignore the rest?</p>
<code>
use strict;
use warnings;
use 5.010;
my %states;
while (<DATA>) {
chomp;
if (/^ ([^:]+) : \s+ (.*)/x) {
$states{$1} = $2;
}
}
use Data::Dumper;
print Dumper \%states;
__DATA__
Controller Status: Optimal
NCQ status: Enabled
Status of logical device: Optimal
Power State: RPM
Supported Power State: RPM, Powered off
</code>
<p>Prints</p>
<code>
$VAR1 = {
'Supported Power State' => 'RPM, Powered off',
'Power State' => 'RPM',
'NCQ status' => 'Enabled',
'Status of logical device' => 'Optimal',
'Controller Status' => 'Optimal'
};
</code>
<p>So all the interesting (and some of the uninteresting) data is in <c>%states</c>.
<!-- Node text goes above. Div tags should contain sig only -->
<div class="pmsig"><div class="pmsig-616540">
[http://perl6.org/|Perl 6 - the future is here, just unevenly distributed]
</div></div>
1047309
1047309