Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
Hello everyone - I have a log file which is in the following format:
19476 2013-04-05,12:10:51.909293 host:internal.machine44.company.net main INFO Running normally with ACTION=<processing> FAN_A=<OK> FAN_B=<OK> SEND=<Sent mail (221 2.0.0 Service closing transmission channel)> FAILURE=<2>
What I'd like to do is split this into a few different pieces. The first number is a line number and I do not need it, as well as the host: information. So I'd like to get the data into this format:
$date => 2013-04-05,12:10:51.909293 $info[ACTION] => processing $info[FAN_A] => OK $info[FAN_B] => OK $info[SEND] => Sent mail (221 2.0.0 Service closing transmission chann +el) $info[FAILURE] => 2
I can do this by using performing multiple greps, but can someone show me if there is a more efficient way to read the information in and use the items such as FAN_A and FAN_B as elements for the array and the value inserted from the information between the <>s?
Thanks in advance.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Some assistance with splitting variables
by hdb (Monsignor) on Apr 05, 2013 at 20:28 UTC | |
|
Re: Some assistance with splitting variables
by Skeeve (Parson) on Apr 05, 2013 at 20:17 UTC | |
|
Re: Some assistance with splitting variables
by kcott (Archbishop) on Apr 06, 2013 at 06:17 UTC | |
|
Re: Some assistance with splitting variables
by ww (Archbishop) on Apr 05, 2013 at 21:53 UTC |