Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Re: Extract Block Of Text From Log

by kcott (Archbishop)
on Nov 21, 2018 at 08:41 UTC ( [id://1226111]=note: print w/replies, xml ) Need Help??


in reply to Extract Block Of Text From Log

G'day ImJustAFriend,

Looking at the code you've posted, I'm wondering if you were trying to adapt the solution I provided to you in "Re: Multiple Line Regex Not Working". If so, it seems there may be some part(s) you didn't understand. Please ask if this is still the case.

I put your input data in a file this time and wrote the following script. Compare it with the last one.

#!/usr/bin/env perl use strict; use warnings; use autodie; my $file = 'pm_1226079_input.txt'; my $SEP = '-' x 40 . "\n"; open my $fh, '<', $file; { local $/ = "\n******************* NRG location"; while (<$fh>) { chomp; /parameters after change .+?\n(.*)\z/ms && print "$SEP$1\n"; } }

Notes:

  • Use a lexical filehandle. See open.
  • Always localise changes to special variables in the smallest scope possible. These are global variables and you don't want these changes propagated throughout your entire script. See also perlvar (and its multiple uses of local throughout).
  • The autodie pragma takes care of all of the "... or die "...";" parts of your script. It saves you having to write them: they're easy to forget; and easy to get wrong (such as leaving out the name of the file that failed to open :-)

Here's the output from that script:

---------------------------------------- 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 ---------------------------------------- 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

— Ken

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1226111]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others browsing the Monastery: (8)
As of 2024-04-18 11:52 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found