Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery

Re: Extract Block Of Text From Log

by kcott (Bishop)
on Nov 21, 2018 at 08:41 UTC ( #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"; } }


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

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

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (6)
As of 2021-05-14 14:23 GMT
Find Nodes?
    Voting Booth?
    Perl 7 will be out ...

    Results (150 votes). Check out past polls.