while($nodepart =~ m/node\s* \{\s* title:\s* "([^"]*)"\s* loc\s* \{\s* x:\s* (\d+)\s* y:\s* (\d+)\s* \}\s* \}\s*/gx){ build_the_structure_with_captured_node($1,$2,$3); }