use Data::Dumper; # get you datafile into a scalar variable (sample put in __DATA__) my $data = join '', ; my $split_pat = qr/-{28}\n([\w\d\.-]+)\n-{28}\n*/; my @data = split /$split_pat/, $data; shift @data; %servers = @data; for my $server (keys %servers) { my %progs = split /\n{2,}/, $servers{$server}; $servers{$server} = \%progs; for my $prog ( keys %{$servers{$server}} ) { my @data = split /\n+/, $servers{$server}->{$prog}; $servers{$server}->{$prog} = \@data; } } print Dumper \%servers; __DATA__ Dumper output: $VAR1 = { 'Server1.dom.com' => { 'WINDOWS 2000 SERVER SP2' => [ 'WARNING MS01-022 Q296441', 'Patch NOT Found MS02-001 Q311401', 'Patch NOT Found MS02-006 Q314147', 'Patch NOT Found MS02-012 Q313450', 'Patch NOT Found MS02-013 Q300845', 'Patch NOT Found MS02-014 Q313829' ], 'Internet Information Services 5.0' => [ 'Patch NOT Found MS02-001 Q311401', 'Patch NOT Found MS02-012 Q313450' ], 'Internet Explorer 5.5 SP2' => [ 'Patch NOT Found MS02-005 Q316059', 'Patch NOT Found MS02-009 Q318089' ] }, 'Server2.dom.com' => { 'WINDOWS 2000 SERVER SP2' => [ 'WARNING MS01-022 Q296441', 'Patch NOT Found MS02-001 Q311401', 'Patch NOT Found MS02-006 Q314147', 'Patch NOT Found MS02-013 Q300845', 'Patch NOT Found MS02-014 Q313829' ], 'Internet Explorer 5.5 SP1' => [ 'Patch NOT Found MS02-005 Q316059', 'Patch NOT Found MS02-009 Q318089' ] } };