# ArrayReferenz = get_datasets( FileHandle) sub get_datasets { my $handle = shift; my @datasets; # read blockwise; separate at double newline local $/ = "\n\n"; while ( my $dataset = <$handle> ) { # remove double newline from dataset chomp $dataset; # first split by newline, then at the first ':' # identifiers must not contain ':' themselves # store splitted fields in a new hash my %set = map { split m{\s*:\s*}, $_, 2 } split( m{\n}, $dataset ); # store reference to new hash in array push @datasets, \%set; } # return array reference return \@datasets; }