Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re: Extract Block Of Text From Log

by GrandFather (Saint)
on Nov 20, 2018 at 22:21 UTC ( #1226081=note: print w/replies, xml ) Need Help??


in reply to Extract Block Of Text From Log

Your while loop is handling blocks, not lines in each block. One fix is:

#!/bin/perl use strict; use warnings; local $/ = "END OF REPORT\n"; while (<DATA>) { my @lines = split /\n/; for (@lines) { print if /\*\sparameters after change\s\=/ .. /\*\sNRG locatio +n\s\=/; } } __DATA__ <13>Nov 13 17:27:25 OamCOMM[12260]: TIMESTAMP=Tue Nov 13 17:27:25 2018 MSGCLS=OAMOPE Title=OAM Create OPERATION Severity=Inform ...

or just:

#!/bin/perl use strict; use warnings; while (<DATA>) { print if /\*\sparameters after change\s\=/ .. /\*\sNRG location\s\ +=/; } __DATA__ <13>Nov 13 17:27:25 OamCOMM[12260]: TIMESTAMP=Tue Nov 13 17:27:25 2018 ...
Optimising for fewest key strokes only makes sense transmitting to Pluto or beyond

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (3)
As of 2021-05-11 22:47 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Perl 7 will be out ...





    Results (123 votes). Check out past polls.

    Notices?