my %x = map { /^=([^\n]*)=\n.*\n===Comments===\n(.*)$/s ? ( $1 => $2 ) : () } split(/(?=^=[^=])/m,$str); print Dumper(\%x);