in reply to question on data structure
Using the data you posted, it dumps:#!/usr/bin/perl use strict; use warnings; my @data; my $keys = 'Log Name|Source|Date|Event ID'; { local $/ = ''; while (<DATA>) { chomp; my %temp = /($keys): (.+)/g; if (/^\s+Description:\s+(.+)\z/sm) { $temp{description} = $1; } push @data, \%temp; } } use Data::Dumper; print Dumper \@data;
Chris$VAR1 = [ { 'Event ID' => '7320', 'Log Name' => 'Microsoft-Windows-GroupPolicy/Operational', 'Source' => 'Microsoft-Windows-GroupPolicy', 'description' => 'Error: Computer determined to be not in +a site. Error code 0x77F.', 'Date' => '2014-06-26T13:58:04.290' }, { 'Event ID' => '7320', 'Log Name' => 'Microsoft-Windows-GroupPolicy/Operational', 'Source' => 'Microsoft-Windows-GroupPolicy', 'description' => 'Error: Computer determined to be not in +a site. Error code 0x77F.', 'Date' => '2014-06-26T12:32:30.009' } ];
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: question on data structure
by natxo (Scribe) on Jul 07, 2014 at 20:30 UTC | |
by Cristoforo (Curate) on Jul 07, 2014 at 22:46 UTC |