Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Re: Extract Block Of Text From Log

by GrandFather (Saint)
on Nov 20, 2018 at 22:21 UTC ( [id://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
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1226081]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others imbibing at the Monastery: (7)
As of 2024-04-18 06:47 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found