0

Hi,

I want to search the log file for a string and extract all data until the end of that line where the search string is found.
For example:

A line in the file reads like below:
[28/04/2010 11:17:53 GMT]PositionPoolCalculation.java(339):getPosCalculation[INFO]BUNP: B123456:1234567:ABCD ANP: B123456:1234567:ABCD:2 post LCN: DESabcdefgh

I want to search for string BUNP and then extract "B123456:1234567:ABCD ANP: B123456:1234567:ABCD:2 post LCN: DESabcdefgh"

while ($record = <INPUT>){

# the below condition reads until the work LCN, but I need it until the end of the line

       if ($record =~ m/BU_NP: (.*?) LCN/) { 
              print "$1\n";
          }
         else{
            print "No Match\n";
         }
};

Any help would be appreciated!

Thanks

2
Contributors
2
Replies
3
Views
7 Years
Discussion Span
Last Post by Perlhelp
1

if ($record =~ m/BUNP:\s*(.*)$/) { #Allow optional space, then capture to end of line

0

Hi d5e5,

Thanks for the solution!!! it worked well for me :)

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.