ImJustAFriend has asked for the wisdom of the Perl Monks concerning the following question:
Greetings again. I have tried I don't know how many different things to get this block extracted from this log file. Here is a sample of the log showing 2 records:
There are MANY entries in the log, all formatted like above - more or less data between "parameters after change" and before "NRG location", sometimes other blocks of data that are irrelevant to what I'm trying to accomplish here. So far, I have tried using the flip-flop operator in various combinations, regex in various combinations... I don't know what else to try. This file is read in a while loop. My goal is to basically extract the block of lines between "parameters after change" and "NRG location". My current test code looks like this:<13>Nov 13 17:27:25 OamCOMM[12260]: TIMESTAMP=Tue Nov 13 17:27:25 2018 MSGCLS=OAMOPE Title=OAM Create OPERATION Severity=Inform message={username:xxxx@::xxxx:xxx.xxx.xxx.x; causeDISTINGUISH_NAME=epsProfileId=xxxxx,pSProfileDataId=x,subscripti +onProfileDataId=x,managedElementId=xxxx USER_LABEL= ******************* parameters after change =******************* epsMaxRequestedBandwidthUL=xxxxxxxxx epsMaxRequestedBandwidthDL=xxxxxxxxx epsQosAllocRetPrioVulnerabilit=xxxxxxx epsQosAllocRetPrioCapability=xxxxxxx epsQosAllocRetPrioLevel=xxxxxxxxx epsQosClassId=xxxxxx sessionTimeout=xxxxxxx idleTimeout=xxxx epsChargingCharacteristics=xxxxxx epsVplmnDynamicAddrAllowed=xxxxxxxxxx epsGwAllocType=xxxxxx epsPdnType=xxxxxx epsAccessPointName=xxxxxx.xxxxxxx ******************* NRG location =******************* NRG_KEY=x } Message Id=10011 END OF REPORT <13>Nov 13 17:27:25 OamCOMM[12260]: TIMESTAMP=Tue Nov 13 17:27:25 2018 MSGCLS=OAMOPE Title=OAM Create OPERATION Severity=Inform message={username:xxxx@::xxxx:xxx.xxx.xxx.x; causeDISTINGUISH_NAME=packetDataProtocolProfileId=xxxxx,gPacketProtoc +olProfileDataId=x,pSProfileDataId=x,subscriptionProfileDataId=x,manag +edElementId=xxxx USER_LABEL= ******************* parameters after change =******************* meanThroughPutClass=xxxxxx peakThroughPutClass=xxxxx reliabilityClass=xxxx delayClass=xxxx precedenceClass=xxxxx hSDPAguaranteeFlag=x hSUPAguaranteeFlag=x hSUPAflag=x hSDPAflag=x downlinkGuaranteedBR=xxx uplinkGuaranteedBR=xx trafficHandlingPriority=xxxxxxx transferDelay=xx ratioSduError=xxxx residualBER=xxxx downlinkMaxBR=xxx uplinkMaxBR=xx maxSduSize=xxx deliveryOfErroneousSdu=xx deliveryOrder=xx trafficClass=xxxxxxxx priorityOfUmtsBearer=xxxxxxx vplmnAddressAllowedFlag=x pdpChargingCharacteristic=xxxxxx accessPointName=xxxxxx.xxxxxxx pdpType=xxxx ******************* NRG location =******************* NRG_KEY=x } Message Id=10011 END OF REPORT
This really shouldn't be this hard, which tells me I must be missing something simple. Any thoughts?#!/bin/perl use strict; use warnings; use Data::Dumper; my $file = "t.txt"; local $/ = "END OF REPORT\n"; open IN, "<", $file or die "IN: $!\n"; while (<IN>) { print if /\*\sparameters after change\s\=/ .. /\*\sNRG locatio +n\s\=/; }
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Extract Block Of Text From Log
by davido (Cardinal) on Nov 20, 2018 at 22:29 UTC | |
Re: Extract Block Of Text From Log
by GrandFather (Saint) on Nov 20, 2018 at 22:21 UTC | |
Re: Extract Block Of Text From Log
by LanX (Saint) on Nov 20, 2018 at 22:19 UTC | |
by LanX (Saint) on Nov 20, 2018 at 22:44 UTC | |
Re: Extract Block Of Text From Log
by cavac (Parson) on Nov 21, 2018 at 06:58 UTC | |
by LanX (Saint) on Nov 21, 2018 at 12:22 UTC | |
by cavac (Parson) on Nov 23, 2018 at 10:04 UTC | |
by LanX (Saint) on Nov 23, 2018 at 10:22 UTC | |
by cavac (Parson) on Nov 23, 2018 at 12:14 UTC | |
Re: Extract Block Of Text From Log
by kcott (Archbishop) on Nov 21, 2018 at 08:41 UTC | |
Re: Extract Block Of Text From Log
by tybalt89 (Monsignor) on Nov 21, 2018 at 08:30 UTC | |
Re: Extract Block Of Text From Log
by ImJustAFriend (Scribe) on Nov 21, 2018 at 16:53 UTC |
Back to
Seekers of Perl Wisdom