use strict; use warnings; # global vars my ( $hash_ref, $logname, $source, $date, $evt_id, $error, $description) ; # we'll increase this after every line in the while loop my $count = 1; # get every line and save it in $line. # then separate the lines in $key/$value pairs divided by ':' while ( my $line = ) { # a paragragh is a line $/ = ""; chomp $line; my @line = split( /[\n\r]/, $line ); for (@line) { next if $_ =~ /^\w+.*$/; next if $_ =~ /\s+Description.*$/; my ( $key, $value ) = split(/: /); if ( $key =~ m/^\s+Log Name.*$/ ) { $logname = $value; } elsif ( $key =~ m/^\s+Source.*$/ ) { $source = $value; } elsif ( $key =~ m/^\s+Date.*$/ ) { $date = $value; } elsif ( $key =~ m/^\s+Event ID.*$/ ) { $evt_id = $value; } elsif ( $key =~ m/^\s+Level.*$/ ) { $error = $value; } $hash_ref->{$count} = { Logname => $logname, Source => $source, Date => $date, "Event ID" => $evt_id, Error => $error, }; } $count++; } use Data::Dumper; print Dumper $hash_ref; __DATA__ here is the dump with the format at the beginning