#!/usr/bin/perl use strict; # https://perlmonks.org/?node_id=11147096 use warnings; my $testdata = < $2 } ] : /\G([^{}\s]+) \{/gc ? [ @$e, { "$1" => (expr(), /\G\}/gc || die pos($_), ' b missing }', substr $_, pos($_))[0] } ] : /\G([^{}\s]+)/gc ? [ @$e, $1 ] : return fixhash($e) while 1; }