awohld has asked for the wisdom of the Perl Monks concerning the following question:
use strict; use warnings; local $/= "\n="; while (my $line = <DATA>) { print "\n------------------------------\n"; if ($line =~ m/Primary \(Reporting\) Cp\s*:\s*((?:(?!Set).)*)Set\s*:\s +*((?:(?!Car).)*)Car\s*:\s*((?:(?!Ref).)*)/si) { print "Cp:$1 - Set:$2 - Car:$3"; } if ($line =~ m/Phase\s*:\s*((?:(?!Strength).)*)Strength\s*:\s*((?:(?!\ +n).)*)/si) { print "\nPhase:$1 - Strength:$2\n"; } while ($line =~ m/(?<!Primary \(Reporting\) )(?<!Secondary Sector)Keep +\s*:\s*((?:(?!offset).)*)offset\s*:\s*((?:(?!Strength).)*)Strength\s* +:\s*((?:(?!Ref).)*)/gsi) { print "Keep:$1 - offset:$2 - Strength:$3\n"; } print "\n------------------------------\n"; } __DATA__ ==================================================================== Record: 9851329 Version: 2 Timestamp: Sat Feb 11 22:39:43 2006 Primary (Reporting) Cp: 113 Set: 2 Car: 1 Ref: yes Event: 9922 Missing P: Keep: 1 Phase: 0x2fdf Strength: 24 Secondary Sector Information: ==================================================================== Record: 9851330 Version: 2 Timestamp: Sat Feb 11 22:39:43 2006 Primary (Reporting) Cp: 115 Set: 1 Car: 2 Ref: yes Event: 9923 Missing P: Keep: 1 Phase: 0x7d10 Strength: 31 Secondary Sector Information: Slot 1: Keep: 1 offset: 391 Strength: 27 Ref: no Slot 2: Keep: 1 offset: 325 Strength: 38 Ref: no
------------------------------ Cp:113 - Set:2 - Car:1 Phase:0x2fdf - Strength:24 ------------------------------ ------------------------------ Cp:115 - Set:1 - Car:2 Phase:0x7d10 - Strength:31 Keep:1 Phase: 0x7d10 Strength: 31 Secondary Sector Information: Slot 1: Keep: 1 - offset:391 - Strength:27 Keep:1 - offset:325 - Strength:38 ------------------------------
------------------------------ Cp:113 - Set:2 - Car:1 Phase:0x2fdf - Strength:24 ------------------------------ ------------------------------ Cp:115 - Set:1 - Car:2 Phase:0x7d10 - Strength:31 Keep:1 Phase: 0x7d10 Strength: 31 Keep:1 - Pn_offset:391 - Strength:27 Keep:1 - Pn_offset:325 - Strength:38 ------------------------------
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Need help modifying parse program.
by TedPride (Priest) on Mar 04, 2006 at 18:26 UTC | |
|
Re: Need help modifying parse program.
by GrandFather (Saint) on Mar 04, 2006 at 19:48 UTC | |
|
Re: Need help modifying parse program.
by matze (Friar) on Mar 04, 2006 at 18:44 UTC |