my %desc = init_desc(); dd \%desc; sub init_desc { (undef,my %hash) = # ignore first line split /^ \[ (\w+) \] \s* $/xm, <<'__ENDS__'; [ONE] one [TWO] two __ENDS__ return %hash; }