my $string = '[1,962,[["x",0,"0.1","1.106"]]][1,963,[["x",0,"0.663","0.0"]]]'; $string .= '[1][1,562,[["x",0,"0.579","1.1"]]][1,563,[["x",0,"0.546","0.0"],["x",0,"0.94","1.8"]]]'; Erhofft: [1,962,[["x",0,"0.1","1.106"]]] [1,963,[["x",0,"0.663","0.0"]]] [1] [1,562,[["x",0,"0.579","1.1"]]] [1,563,[["x",0,"0.546","0.0"],["x",0,"0.94","1.8"]]] Realitaet: [1,962,[["x",0,"0.1","1.106"]]] [["x",0,"0.663","0.0"]]] [1,562,[["x",0,"0.579","1.1"]]]