ImJustAFriend has asked for the wisdom of the Perl Monks concerning the following question:
For troubleshooting purposes I extracted one "chunk" of the log and put it into a text file t.txt. I then crafted t.pl to see if I could get the coding to work without impacting my larger script. Basically, I need to capture everything between "message=" and "Message Id" for this log entry. I am thinking in an array for processing after extraction. I have literally tried 40 different ideas, either my own or found on internet search, and nothing works. Here's my t.pl code I'm trying to make work:<13>Nov 15 21:26:00 OamCOMM[365626]: TIMESTAMP=Thu Nov 15 21:26:00 2018 MSGCLS=OAMOPE Title=OAM Create OPERATION Severity=Inform message={username:xxxxxxxx@xxxxxxxxxxxxxxxxxxx; causeDISTINGUISH_NAME=label=x,label=x,;label=x,label=xxxxxxxxxxxxxxx, +label=x,label=xxxx USER_LABEL= ******************* parameters after change =******************* label=xxxxxxxxxxxxx label=xxxxxxxxxxxxxxxxxxxxxxx label=xxxxxxxxxxxxxxxxxxxxxxxxxxxx label=sxxxxxxxxxxxxxxxxxxxxxxxxxxxxx label=xxxxxxxxxxxx ******************* xxxxxxxxxxxx =******************* label=x } Message Id=xxxxxxxx
When I execute this script, I get:#!/bin/perl use strict; use warnings; use Data::Dumper; my $mlsf = "t.txt"; my @res; open IN, "<", $mlsf or die "IN: $!\n"; while (my $mls = <IN>) { @res = $mls =~ m/^.*message=(.*?)Message Id.*$/gs; } print Dumper (\@res);
Anyone have any ideas?$VAR1 = [];
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Multiple Line Regex Not Working
by jwkrahn (Abbot) on Nov 15, 2018 at 22:34 UTC | |
by ImJustAFriend (Scribe) on Nov 16, 2018 at 12:33 UTC | |
|
Re: Multiple Line Regex Not Working
by kcott (Archbishop) on Nov 16, 2018 at 07:12 UTC |