#!/usr/bin/perl use strict; use warnings; use Data::Dumper; my @entries; { local $/ = "\n\n"; open(my $fh,'<',$ARGV[0]) or die $!; while(my $entry = <$fh>){ push(@entries,$entry) if($entry =~ /Severity: Error/s); } close $fh; } print Dumper(\@entries);