use Data::Dump; my %desc=init_data(); dd \%desc; sub init_data { my $sep = "\n=====\n"; local $/ = $sep; my %hash; while () { s/$sep$//; # kill separator s/^(.*)\n//; # first line is key string $hash{$1} = $_; } return %hash; } __DATA__ ONE one ===== TWO two two ===== THREE Three three