#!/usr/bin/perl -w use strict; my @arrayAoH = ""; my $out = "First one: one Second one: second"; my @discovered = split /\n/, $out; my $i = 0; # i holds the line number of the input (@discovered) array. my $j = 0; # j holds the number of the table row. my $key; my $value; # $# returns the subscript of the last element in the array. until ($i eq $#discovered){ if ($discovered[$i] =~ m/First one:/){ # parse this line containing labels and values until a blank line is found until ($discovered[$i] eq ""){ ($key, $value) = split /:\s*/, $discovered[$i]; ## $arrayAoH[$j] = { $key => $value }; $arrayAoH[$j]{$key} = $value; $i++; } $j++; } else { $i++;} }