#!/usr/bin/perl use strict; use warnings; use Data::Dumper; my @entries; my @filtered; my $event = {}; while (<>) { chomp; unless ($_) { push @entries, $event if keys %$event; $event = {}; next; } if (/^(\w+):\s?(.+)$/) { $event->{$1} = $2; } else { $event->{msg_text} .= $_."\n"; } } @filtered = grep { $_->{Severity} =~ /Error/ } @entries; die Dumper \@filtered;