Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight

Re: Help with my regex

by moritz (Cardinal)
on Aug 01, 2013 at 05:38 UTC ( #1047355=note: print w/replies, xml ) Need Help??

in reply to Help with my regex

How about just parsing the whole thing, and afterward using those fields you're interested in, and simply ignore the rest?

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


$VAR1 = { 'Supported Power State' => 'RPM, Powered off', 'Power State' => 'RPM', 'NCQ status' => 'Enabled', 'Status of logical device' => 'Optimal', 'Controller Status' => 'Optimal' };

So all the interesting (and some of the uninteresting) data is in %states.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1047355]
[Corion]: Hmmm - and now that I look at it, the gallery I'm using doesn't produce non-Javascript compatible links in the sense that hotlinking to an image will only work for Javascript enabled...
[Corion]: On the other hand, maybe supporting non-Javascript isn't that much a priority, and I'm not exactly sure how I could make it work for both kinds of browsers without server-side magic
[Corion]: Should I ever come across far too much money, this would become my evil maniac lair ;)

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (10)
As of 2017-02-27 08:36 GMT
Find Nodes?
    Voting Booth?
    Before electricity was invented, what was the Electric Eel called?

    Results (377 votes). Check out past polls.