in reply to Help with my regex
Every line there except for the blank one, does indeed have either "power" or "status" somewhere in it.
If your set is as small as the example, you might be best off listing all of the options in a long enough form to make them unique. This specifies exactly what should be found before the first colon on the line.
# Maybe make the values here a sub reference defining what to call whe +n you see the line in question. my %wantedInfoHash = ('Controller Status' => undef, 'Status of logical device' => undef, ...); while ($line = <>) { if ($line =~ /([^:]):/) { # grabbed everything up to the first colon into $1 if (exists $wantedInfoHash{$1}) { # Found something we wanted, so do something with it. } } }
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: Help with my regex
by cspctec (Sexton) on Jul 31, 2013 at 21:13 UTC | |
by Preceptor (Deacon) on Jul 31, 2013 at 21:25 UTC | |
by SuicideJunkie (Vicar) on Jul 31, 2013 at 21:36 UTC |
In Section
Seekers of Perl Wisdom